Is std :: vector <int, std :: allocator <char>> valid?
The standard does not say anything about the distributor std::vector, but it is only required that the distributor satisfy the concept Allocator. Nothing about the value_type allocator, no reference_type, nothing.
I thought it std::vector<T, A>internally overloaded Ainto the dispenser for T, so I gave a vector std::allocator<char>and worked as expected.
However, GCC generates errors if specified std::allocator<void>as shown below:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/alloc_traits.h: In instantiation of ‘struct __gnu_cxx::__alloc_traits<std::allocator<void> >’:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/stl_vector.h:75:28: required from ‘struct std::_Vector_base<int, std::allocator<void> >’
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/stl_vector.h:214:11: required from ‘class std::vector<int, std::allocator<void> >’
a.cpp:5:42: required from here
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/alloc_traits.h:109:53: error: forming reference to void
typedef value_type& reference;
^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/alloc_traits.h:110:53: error: forming reference to void
typedef const value_type& const_reference;
^
Is this a GCC bug? or am I misunderstanding the standard?
- GCC Version: 4.9.2
+4
1 answer
