C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: std::variant - going from Alternative& to the enclosing variant&
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2020-08-21 09:47:05


On Fri, 21 Aug 2020 at 17:33, Victor Khomenko
<victor.khomenko_at_[hidden]> wrote:
> 3. Solution with a new visit-function that provides the variant itself as a parameter to the visitor seems acceptable - but looks more complicated than what I proposed?

I don't think so. The magic-function you suggest would seemingly need
to be told what kind of a variant to convert to.
In the approach I suggest, that's your parameter type. The error
possibility of getting the variant type wrong is not there;
the type and value of the variant is statically correct, as opposed to
possibly being incorrect at run time.


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups