Closed mpark closed 6 years ago
+1 If I had a variant that can ensure the non-empty guaranties I would try to implement std::expected wrapping a stdxx::variant.
Note that std::expected could ensure the non-empty guaranties as the type E must be nothrow as used to report errors.
It's not clear to me how this ticket would help with the implementation of expected
. Even if E
is required to be nothrow move, T
doesn't have that requirement right? So it seems to me like it wouldn't help in the general case? or does expected
have optional
-like behavior where it falls back to the default-constructed error state or something?
Hrr, maybe you are right and I was thinking on P0110R0. No, neither std::expected nor std::optional fallbacks, at least I don't remember of that.
Implement section III of P0308 as a non-standard version (outside of
cpp17
namespace).Types such as
variant<int, double>
should not ever get into avalueless_by_exception
state. Something like: