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/whichton Jun 18 '15

There was a proposal for destructive move, but it got rejected I believe. Destructive move is very useful for things like sorting a container.

Problem is C++ constructor does 2 very different things - it allocates memory, whether on stack or heap and then it constructs the object on the heap. C++ has no way to express the "has memory but not yet constructed" state. Hence we often find the default constructed object being used as a proxy, which is incorrect. Stepanov has argued for such a state is his papers, and I believe the destructive move proposal was in response to his ideas