[v3 PATCH] Use single-visitation in variant assignment and swap.

Paolo Carlini paolo.carlini@oracle.com
Mon Apr 1 08:45:00 GMT 2019


Hi

On 01/04/19 10:43, Ville Voutilainen wrote:
> On Mon, 1 Apr 2019 at 11:30, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>> Hi
>>
>> On 30/03/19 19:00, Ville Voutilainen wrote:
>>> -  template<typename _Visitor, typename... _Variants>
>>> +  template<bool __use_index, typename _Visitor, typename... _Variants>
>>> +    decltype(auto)
>>> +    __visitor_result_type(_Visitor&& __visitor, _Variants&&... __variants)
>>> +    {
>>> +      if constexpr(__use_index)
>>> +        return __detail::__variant::__variant_idx_cookie{};
>>> +      else
>>> +     return std::forward<_Visitor>(__visitor)(
>>> +       std::get<0>(std::forward<_Variants>(__variants))...);
>>> +    }
>> If I'm not misreading something, the new function will be usually
>> compiled/optimized to something very small and isn't constexpr thus
>> normally should be explicitly marked inline. Or the problem is the
>> missing constexpr? (sorry, I didn't really study the new code)
> The only use of this function is to compute its return type. It's
> never called. I should probably comment on that...

Oh, yes, now I see, a few lines below. That's clear enough, I think.

Paolo.



More information about the Libstdc++ mailing list