Default std::vector<bool> default and move constructor
François Dumont
frs.dumont@gmail.com
Mon May 15 17:57:00 GMT 2017
Hi
Following what I have started on RbTree here is a patch to default
implementation of default and move constructors on std::vector<bool>.
As in _Rb_tree_impl the default allocator is not value initialized
anymore. We could add a small helper type arround the allocator to do
this value initialization per default. Should I do so ?
I also added some optimizations. Especially replacement of
std::fill with calls to __builtin_memset. Has anyone ever proposed to
optimize std::fill in such a way ? It would require a test on the value
used to fill the range but it might worth this additional runtime check,
no ?
* include/bits/stl_bvector.h (_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.
Tested under Linux x86_64 normal mode, with and without versioned
namespace.
Ok to commit ?
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bvector.patch
Type: text/x-patch
Size: 8584 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170515/ae99b03f/attachment.bin>
More information about the Libstdc++
mailing list