Boost logo

Boost :

Subject: Re: [boost] Review request for variant2, review manager wanted
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2019-02-23 23:41:16


On Sat, Feb 23, 2019, 2:03 AM Bjorn Reese via Boost <boost_at_[hidden]>
wrote:

> On 2/23/19 4:43 AM, Peter Dimov via Boost wrote:
>
> > The main cost/benefit gain over std::variant is that if you need to
> > support C++11 or C++14, std::variant doesn't work. :-)
>
> The main appeal for me is the well-designed avoidance of the valueless-
> by-exception state.

Agreed, and I think it's important that we have this, though I've yet to
formally review the implementation.

IMO, std::variant is reasonable for a sum type in the standard library only
in the sense that it works and is all that we could get consensus on, but
it was ultimately a compromise that was lacking in different ways for
different people. From my perspective there are really two core world views
here for a variant design. I won't make a value judgment for which is
"better" because I think that both have their uses, and I think that the
belief that there can only be one is misguided. The core difference between
the two approaches, imo, are:

1) Never empty
2) A variant that has a partially-formed state, as Stepanov would refer to
it ("empty" akin to a default-constructed int). Arguably this is also not
"empty".

std::variant does something kind of straddling of these two worlds and is
less than the ideal in both cases. I would love it if we had a very solid
implementation of (1), and also a solid implementation of (2). If this
satisfies (1), then I'd be very happy.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk