Default std::vector<bool> default and move constructor
François Dumont
frs.dumont@gmail.com
Wed May 31 20:28:00 GMT 2017
On 31/05/2017 12:34, Jonathan Wakely wrote:
>
> Well in general the is_nothrow_default_constructible trait also tells
> you if the type is default-constructible at all, but the form above
> won't compile if it isn't default-constructible. In this specific case
> it doesn't matter, because that constructor won't compile anyway if
> the allocator isn't default-constructible.
>
Thanks for explanation, for the moment I kept the noexcept calls. You'll
tell me if it is fine in this new proposal.
>> I'll complete testing and add a test on this value-initialization
>> before commit if you agree.
So here is the new proposal with the additional test.
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.
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 ?
Now I wonder if I really introduced a regression in rb_tree...
Tested under Linux x86_64.
* include/bits/stl_bvector.h
(__fill_bvector(_Bit_type*, unsigned int, unsigned int, bool)):
Change signature.
(std::fill(_Bit_iterator, _Bit_iterator, bool)): Adapt.
(_Bvector_impl_data): New.
(_Bvector_impl): Inherits from latter.
(_Bvector_impl(_Bit_alloc_type&&)): Delete.
(_Bvector_impl(_Bvector_impl&&)): New, default.
(_Bvector_base()): Default.
(_Bvector_base(_Bvector_base&&)): Default.
(_Bvector_base::_M_move_data(_Bvector_base&&)): New.
(vector(vector&&, const allocator_type&)): Use latter.
(vector<bool>::operator=(vector&&)): Likewise.
(vector<bool>::vector()): Default.
(vector<bool>::assign(_InputIterator, _InputIterator)): Use
_M_assign_aux.
(vector<bool>::assign(initializer_list<bool>)): Likewise.
(vector<bool>::_M_initialize_value(bool)): New.
(vector<bool>(size_type, const bool&, const allocator_type&)): Use
latter.
(vector<bool>::_M_initialize_dispatch(_Integer, _Integer,
__true_type)):
Likewise.
(vector<bool>::_M_fill_assign(size_t, bool)): Likewise.
Ok to commit ?
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bvector.patch
Type: text/x-patch
Size: 13128 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170531/036725f7/attachment.bin>
More information about the Libstdc++
mailing list