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

Standardizing Variant: Difficult Decisions

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

56 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Jun 18 '15 edited Jun 18 '15

I don't know of any widely used variant implementation with a double buffer so I doubt anybody wants to standardize one that does.

What is probably going to happen is that if copy construction fails, an exception will be thrown, and the variant will be left in an invalid state. Using an invalid state will be UB, and that can only happen if the programmer explicitly swallows the exception and uses the variant without assigning it a valid state.

All other alternatives are too complicated and have too many downsides.