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

François Dumont frs.dumont@gmail.com
Wed Oct 12 20:36:00 GMT 2016


On 10/10/2016 23:01, Tim Song wrote:
> Trying again...with a few edits.
>
>> On Mon, Oct 10, 2016 at 3:24 PM, François Dumont <frs.dumont@gmail.com>
>> wrote:
>>
>> @@ -602,24 +612,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>           struct _Rb_tree_impl : public _Node_allocator
>>           {
>>     _Key_compare _M_key_compare;
>> -  _Rb_tree_node_base _M_header;
>> +  _Rb_header_node _M_header;
>> +#if __cplusplus < 201103L
>>     size_type _M_node_count; // Keeps track of size of tree.
>> +#else
>> +  size_type _M_node_count = 0; // Keeps track of size of tree.
>> +#endif
>>
>> +#if __cplusplus < 201103L
>>     _Rb_tree_impl()
>> -  : _Node_allocator(), _M_key_compare(), _M_header(),
>> -    _M_node_count(0)
>> -  { _M_initialize(); }
>> +  : _M_node_count(0)
>> +  { }
>> +#else
>> +  _Rb_tree_impl() = default;
>> +#endif
>
> The default constructor of the associative containers is required to
> value-initialize the comparator (see their synopses in
> [map/set/multimap/multiset.overview]).
I don't have latest Standard version so can't see the exact word but I 
find quite annoying that the Standard doesn't allow this simple 
implementation.

I don't know if unodered containers have same kind of requirements for 
equal or hash functors but if so current implementation doesn't do this 
value initialization.

So here is another attempt. This time it simply allows to have noexcept 
condition in one place and closer to where operations are being invoked.

Ok to commit after tests ?

François
>
>   _Rb_tree_impl() = default; doesn't do that; it default-initializes the
>   comparator instead.
>
> Tim
>

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


More information about the Libstdc++ mailing list