r/cpp • u/_VZ_ wx | soci | swig • Jun 17 '15
Standardizing Variant: Difficult Decisions
https://www.justsoftwaresolutions.co.uk/cplusplus/standardizing-variant.html
31
Upvotes
r/cpp • u/_VZ_ wx | soci | swig • Jun 17 '15
View all comments
Show parent comment
1
u/suspiciously_calm Jun 18 '15
Yes.
It doesn't complicate use, since a variant holding the wrong type is also a real possibility, and it doesn't complicate the design of the type either, since the "invalid state" representation has to be there anyway. The only difference is whether the default constructor constructs an empty variant or one of the variant types which is selected by some arbitrary rule.