5 Mar
2019
5 Mar
'19
7:48 p.m.
On Sun, Mar 3, 2019 at 7:42 AM Gottlob Frege via Boost < boost@lists.boost.org> wrote:
What happens with
struct Bad { operator int() { throw false; } };
variant
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.