|
Boost : |
Subject: Re: [boost] [variant2] documentation request
From: Ivan Matek (libbooze_at_[hidden])
Date: 2019-03-05 19:48:29
On Sun, Mar 3, 2019 at 7:42 AM Gottlob Frege via Boost <
boost_at_[hidden]> 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.
Could variant2 use type_traits on = to require that RHS is int or
short(optionally + const and & and volatile :) )?
I know this will not help with all types(eg std::string or std::vector),
but for PODs it would be nice if we could keep out all the exceptions
outside variant.
Users could still use SometimesBad(that throws sometimes on operator int),
but they would need to do do the conversion to int before assignment.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk