[bugfix] Fix default constructor of Std::variant
The behaviour of the default constructor std::variant<T0, ...> is as follows:
- (a) If
T0is default constructible, then thevariantwill hold a value-initializedT0and the index is 0. - (b) If
T0is not default constructible, then the default constructor does npt participate in overload resolution.
In contrast to this until now the following is implemented
- (c) The default constructor of
Std::variantdoes alway exist and will initialize it with a special invalid state (which is BTW not copyable).
Having (c) instead of (a) especially prevented copying default
constructed Std::variant<Std::monostate, ...> objects.
This patch at least ensures (a) but keeps (c) if T0 is not
default constructible. The reason for the latter is, that (b)
is much harder to fix and unlikely to lead to problems.