Date
2012-12-17.21:46:53
Message id
6232

Content

The forward_list(size_type) constructor has no allocator-extended equivalent, preventing the following code from compiling:

#include <forward_list>
#include <vector>
#include <scoped_allocator>

using namespace std;

int main()
{
  using list = forward_list<int>;
  vector<list, scoped_allocator_adaptor<list::allocator_type>> v;
  v.emplace_back(1u);
}

The very same problem exists for all allocator-aware sequence containers.

In addition it exists for associative containers. For example, it's possible to construct std::set<int>{0, 1, 2} but not std::set<int>{{0, 1, 2}, alloc}, and possible to construct std::set<int>{begin, end} but not std::set<int>{begin, end, alloc}.

This makes the following program fail when SCOPED is defined:

#include <set>
#include <vector>
#include <scoped_allocator>

#if SCOPED
using A = std::scoped_allocator_adaptor<std::allocator<int>>;
#else
using A = std::allocator<int>;
#endif

int main()
{
  int values[] = {0, 1, 2};
  std::vector<std::set<int>, A> v;
  v.emplace_back(std::begin(values), std::end(values));
}