r/cpp • u/_VZ_ wx | soci | swig • Jun 17 '15
Standardizing Variant: Difficult Decisions
https://www.justsoftwaresolutions.co.uk/cplusplus/standardizing-variant.html
32
Upvotes
r/cpp • u/_VZ_ wx | soci | swig • Jun 17 '15
View all comments
Show parent comment
0
u/foonathan Jun 18 '15
No, I want nothing to happen, when visiting an empty variant. And a variant can get empty after being default constructed, manually reset or as a fallback for a failed move.
And you notice a failed move because an exception is thrown. But with a variant which is allowed to be empty, it is safe to access it after the exception without harm. Because it has a valid, well-defined state: it is empty.