Using a slightly modified version of Howard Hinnants's C++11 stack allocator which is documented here, with std::basic_string
and libstdc++
(see it live ):
const unsigned int N = 200;
arena<N> a;
short_alloc<char, N> ac(a) ;
std::basic_string<char,std::char_traits<char>,short_alloc<char, N>> empty(ac);
gives the following error amongst others:
error: no matching function for call to 'short_alloc<char, 200ul>::short_alloc()'
if (__n == 0 && __a == _Alloc())
^
However it works without error when using libc++
(see it live ).
The stdlibc++
implementation of std::basic_string
seems to expect the allocator to have a default constructor.
Does C++11 require allocators to be default constructible? Which implementation is correct?
Aucun commentaire:
Enregistrer un commentaire