[PATCH] 77864 Fix noexcept conditions for map/set default constructors

François Dumont frs.dumont@gmail.com
Thu Oct 6 20:17:00 GMT 2016


On 05/10/2016 14:13, Jonathan Wakely wrote:
> On 05/10/16 14:10 +0200, Marc Glisse wrote:
>> On Wed, 5 Oct 2016, Jonathan Wakely wrote:
>>
>>> I added conditional noexcept to maps and sets, but forgot to account
>>> for the comparison function, which could throw when constructed.
>>
>> IMO you are fighting a losing battle. We should implement 
>> noexcept(auto) (possibly with some private __noexcept_auto__ 
>> spelling) and just use that in most places where we want a 
>> conditional noexcept.
>
> That would be nice, but beyond my ability :-)
>
> So until then we can either remove the exception specs entirely, or
> make them correct.
>
>
Another approach is to rely on existing compiler ability to compute 
conditional noexcept when defaulting implementations. This is what I 
have done in this patch.

The new default constructor on _Rb_tree_node_base is not a problem as it 
is not used to build _Rb_tree_node.

I'll try to do the same for copy constructor/assignment and move 
constructor/assignment.

     * include/bits/stl_map.h (map()): Make default.
     * include/bits/stl_multimap.h (multimap()): Likewise.
     * include/bits/stl_multiset.h (multiset()): Likewise.
     * include/bits/stl_set.h (set()): Likewise.
     * include/bits/stl_tree.h (_Rb_tree_node_base()): New.
     (_Rb_tree_impl()): Make default.
     (_Rb_tree_impl::_M_initialize()): Delete.
     (_Rb_tree()): Make default.

Tested under Linux x86_64, ok to commit ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: default_dflt_const.patch
Type: text/x-patch
Size: 5204 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20161006/800eaad3/attachment.bin>


More information about the Libstdc++ mailing list