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

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


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)

Paolo.




More information about the Libstdc++ mailing list