r/cpp • wx | soci | swig • Jun 17 '15

Standardizing Variant: Difficult Decisions

https://www.justsoftwaresolutions.co.uk/cplusplus/standardizing-variant.html
32 Upvotes

56 comments sorted by

View all comments

Show parent comment

5

u/_VZ_ wx | soci | swig Jun 17 '15

I was at the committee meeting where this was discussed, and I argued strongly in favor of the current design.

I'm very relieved to hear this! It seems so obvious to me that it must be possible to have a never-empty guarantee that I had real trouble believing the committee was seriously considering removing the possibility to have it, which was the impression I got from the original blog post. It's reassuring to know that this is not the case, thanks.

5

u/eric_niebler Jun 17 '15

A valid variant can never be empty. It is possible to have an invalid variant, but only by ignoring exceptions. Well-behaved code doesn't do that.