Default std::vector<bool> default and move constructor

Jonathan Wakely jwakely@redhat.com
Fri Jun 2 10:27:00 GMT 2017


On 01/06/17 22:49 +0200, François Dumont wrote:
>On 01/06/2017 15:34, Jonathan Wakely wrote:
>>On 31/05/17 22:28 +0200, François Dumont wrote:
>>>Unless I made a mistake it revealed that restoring explicit call 
>>>to _Bit_alloc_type() in default constructor was not enough. G++ 
>>>doesn't transform it into a value-init if needed. I don't know if 
>>>it is a compiler bug but I had to do just like presented in the 
>>>Standard to achieve the expected behavior.
>>
>>That really shouldn't be necessary (see blow).
>>
>>>This value-init is specific to post-C++11 right ? Maybe I could 
>>>remove the useless explicit call to _Bit_alloc_type() in pre-C++11 
>>>mode ?
>>
>>No, because C++03 also requires the allocator to be value-initialized.
>
>Ok so I'll try to make the test C++03 compatible.

That would require a much more complicated allocator, so I don't think
it's too important.

If you define the constructor like:

      _Bvector_impl()
      _GLIBCXX_NOEXCEPT_IF( noexcept(_Bit_alloc_type()) )
      : _Bit_alloc_type()
      { }

then it will do the same thing for C++03 as for later versions, so
testing for C++11 only should be good enough.



More information about the Libstdc++ mailing list