Attempt to make std::pair piecewise constructor noexcept

François Dumont frs.dumont@gmail.com
Fri Dec 21 17:21:00 GMT 2018


On 12/21/18 3:00 PM, Ville Voutilainen wrote:
> On Fri, 21 Dec 2018 at 15:47, Jonathan Wakely <jwakely@redhat.com> wrote:
>> On 16/12/18 18:48 +0100, François Dumont wrote:
>>> @@ -372,7 +361,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>>          second(std::forward<_U2>(__p.second)) { }
>>>
>>>        template<typename... _Args1, typename... _Args2>
>>> -        pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>);
>>> +      pair(piecewise_construct_t,
>>> +           tuple<_Args1...> __first, tuple<_Args2...> __second)
>>> +      noexcept( noexcept(
>>> +        pair(declval<tuple<_Args1...>&>(), declval<tuple<_Args2...>&>(),
>>> +             declval<typename _Build_index_tuple<sizeof...(_Args1)>::__type>(),
>>> +             declval<typename _Build_index_tuple<sizeof...(_Args2)>::__type>())) )
>>> +      : pair(__first, __second,
>>> +             typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
>>> +             typename _Build_index_tuple<sizeof...(_Args2)>::__type())
>>> +      { }
>> Surely just:
>>
>>        noexcept(
>>          is_nothrow_constructible<_T1, _Args1...>
>>          &&
>>          is_nothrow_constructible<_T2, _Args2...>
>>        )
>>
>> ?
> Correct. Piecewise construction will end up doing that anyway, and we
> know it will.
>
Indeed, it is simpler and avoids moving a lot of code in different 
headers. It just make hypothesis on implementation details which I 
usually try to avoid.

Good point for anyone willing to push such a patch. But not me as I have 
no interest to do so anymore.

Thanks



More information about the Libstdc++ mailing list