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

Standardizing Variant: Difficult Decisions

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

56 comments sorted by

View all comments

Show parent comment

1

u/vlovich Jun 17 '15

I thought so as well but the article explains it better than I can:

Secondly, it changes the order of operations: the old value is not destroyed until after the new one has been constructed, which can have surprising consequences if you are not expecting it.

0

u/F-J-W Jun 17 '15

You can say that just about everything, I fail to see how this specific thing affects code that isn't terrible to begin with though.

2

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

What else can you say this about? Such "out of order" execution almost invariably leads to at least some problems and it would clearly be better to not have it even if, admittedly, this is a second order concern compared to not allowing empty variants which is absolutely critical IMO.