5 Apr
2019
5 Apr
'19
5:03 p.m.
Andrzej Krzemienski wrote:
A possibly-empty variant can be well approximated by adding `monostate` as one of the alternatives. This is recognized by `variant` as the empty state, and is preferentially used as a fallback on exception. If monostate is the first alternative, as is the common case, variant will default-construct to it.
Does this happen *only* when `monostate` is at index 0, or when `monostate` is at any index? I thought from the sources that `monostate` on any index gives the guarantee.
Like std::variant, variant2 always default-constructs to the first
alternative. That is, the default constructor of variant