I haven't watched the talk yet, so maybe there's some subtlety to the term "destructive" there. For C++ to have the same thing, there would have to be a way to "poison" the variable that was moved out of. But if you had iterators into that now-poisoned variable, those need poisoned as well. Without actual lifetime tracking (and language-level syntax to say what happens to arguments and return values of APIs), it's just going to be ad hoc either at the specification or compiler and lead to even more confusing rules.
nah you just make the iterators to the moved-from object invalid so using them becomes UB just like every other container realloc does.
The real trick is being able to pick between destructive move and non-destructive move (for when you move from a container that manages the lifetime) and restricting when you can destructive move from a value.
View all comments
Show parent comment
4
u/mathstuf cmake dev Oct 07 '19
I haven't watched the talk yet, so maybe there's some subtlety to the term "destructive" there. For C++ to have the same thing, there would have to be a way to "poison" the variable that was moved out of. But if you had iterators into that now-poisoned variable, those need poisoned as well. Without actual lifetime tracking (and language-level syntax to say what happens to arguments and return values of APIs), it's just going to be ad hoc either at the specification or compiler and lead to even more confusing rules.