5 Mar
2019
5 Mar
'19
9:57 p.m.
Ivan Matek 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.
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: https://godbolt.org/z/8kXcBN