|
Boost : |
Subject: Re: [boost] [variant2] documentation request
From: Peter Dimov (pdimov_at_[hidden])
Date: 2019-03-05 21:57:38
Ivan Matek wrote:
> > What happens with
> >
> > struct Bad
> > {
> > operator int() { throw false; }
> > };
> >
> > variant<int, short> v = (short)10;
> > v = Bad();
>
> I always considered this ugly corner case that prevents us from having
> nice things.
This is actually not a problem for variant2. When the contained types are
trivial, as in this case, the exception, if any, occurs outside the variant.
It has to, because otherwise constexpr can't work:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk