Forward list default default and move constructors

François Dumont frs.dumont@gmail.com
Mon Jun 19 20:48:00 GMT 2017


Hi

     Here is the patch to default the default and move constructors on 
the std::forward_list. Putting a move constructor on _Fwd_list_node_base 
helped limiting the code impact of this patch. It doesn't have any side 
effect as iterator types using this base type are not defining any move 
semantic.

     I also took the time to optimize the move constructor with 
allocator when allocator is always equal. It avoids initializing an 
empty forward list for nothing.

     I think it is fine but could we have an abi issue because of the 
change in forward_list.tcc ?

     * include/bits/forward_list.h
     (_Fwd_list_node_base(_Fwd_list_node_base&&)): New.
     (_Fwd_list_impl()): Add noexcept qualification.
     (_Fwd_list_impl(_Fwd_list_impl&&)): New, default.
     (_Fwd_list_impl(_Fwd_list_impl&&, _Node_alloc_type&&)): New.
     (_Fwd_list_base()): Default.
     (_Fwd_list_base(_Fwd_list_base&&, _Node_alloc_type&&, true_type)): New.
     (_Fwd_list_base(_Fwd_list_base&&, _Node_alloc_type&&, false_type)): 
New.
     (_Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a)): Use
     latter.
     (_Fwd_list_base(_Fwd_list_base&&)): Default.
     (forward_list<>()): Default.
     (forward_list<>(forward_list&&)): Default.
     * include/bits/forward_list.tcc
     (_Fwd_list_base(_Fwd_list_base&&, _Node_alloc_type&&, false_type)): 
New.
     * testsuite/23_containers/forward_list/allocator/default_init.cc: New.

Tested under Linux x86_64, ok to commit ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: forward_list.h.patch
Type: text/x-patch
Size: 6500 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170619/d83f89ae/attachment.bin>


More information about the Libstdc++ mailing list