Rb_tree constructor optimization

François Dumont frs.dumont@gmail.com
Wed Sep 13 19:57:00 GMT 2017


On 08/09/2017 17:50, Jonathan Wakely wrote:
>
> Since we know __a == __x.get_allocator() we could just do:
>
>      _Rb_tree(_Rb_tree&& __x, _Node_allocator&&, true_type)
> noexcept(is_nothrow_move_constructible<_Rb_tree_impl<_Compare>>::value)
>      : _M_impl(std::move(__x._M_impl))
>      { }
>
> This means we don't need the new constructor.

     You want to consider that a always equal allocator is stateless and 
so that the provided allocator rvalue reference do not need to be moved. 
IMHO you can have allocator with state that do not participate in 
comparison like some monitoring info.

     I'm not confortable with that and prefer to keep current behavior 
so I propose this new patch considering all your other remarks.

     I change noexcept qualification on [multi]map/set constructors to 
just rely on _Rep_type constructor noexcept qualification to not 
duplicate it.

François


-------------- next part --------------
A non-text attachment was scrubbed...
Name: rb_tree.patch
Type: text/x-patch
Size: 6532 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170913/0aaffddf/attachment.bin>


More information about the Libstdc++ mailing list