Subject: Re: [boost] Outcome v2 is feature complete
From: Peter Dimov (lists_at_[hidden])
Date: 2017-07-11 15:19:41
Niall Douglas wrote:
> I don't understand. variant<...> knows exactly what the alternatives are.
It doesn't know what they mean though. Doesn't know that T1 is the value and
T2 is the error.
> It surely would be straightforward to look at some Arg&&... sequence and
> do std::is_constructible<X, Arg&&...> matching against all possible
> variant states.
The one-argument variant constructor performs overload resolution across all
alternatives and chooses the best match (if one exists.)
This makes it possible for it to sometimes surprise the user with its
Extending this to multiple arguments would be possible in principle, but
it's not that straightforward as you make it seem. It's not just a matter of
checking is_constructible. You need to choose the best match.
> The fact they don't do it I surely think is a deliberate and intentional
> design choice for some hopefully good reason.
I'm not so sure.
`variant` is very tricky to specify, and from a certain point on, people
were so tired of the endless discussions that they shot any new suggestion
down regardless of merits if it had the potential to generate further
I don't remember this even being proposed, but had it been proposed, it
would probably have been rejected summarily without any deliberation,
because it's pretty subtle.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk