
On Wed, Apr 3, 2019 at 2:08 AM Mike via Boost
Mabye I'm blind, but it seems to me that people repeatedly mix up "never empty" and "no error state".
Variant2 can still get into an error state, just that that error state is not explicitly named and modeled as part of variant2, but instead, a "regular" state is reused to signal that error:
What you're missing is that this is a matter of definition. Your definition is: if we enter a state because of an error, then that state is an error state. An alternative definition is: if an assignment operation fails, the object is left in an unspecified but valid state. Under the second definition, it is illogical to call the "unspecified but valid" state an error state that must be checked, because by definition it is a perfectly valid state. Further, this valid state is not "reused to signal that error". It is the result of the error, but the error is communicated by other means, e.g. an exception.