[PATCH] 77864 Fix noexcept conditions for map/set default constructors
François Dumont
frs.dumont@gmail.com
Sun Oct 23 13:54:00 GMT 2016
Hi
I have run all tests with success. Even if it doesn't get rid of
_GLIBCXX_NOEXCEPT_IF it still limits it to one place.
So is it ok to commit ?
François
On 12/10/2016 22:36, François Dumont wrote:
> 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
>>
>
More information about the Libstdc++
mailing list