3 ms·
The biggest problem with destructive move in C++ (and one I personally think is unfixable, but I'm happy to be proved wrong), is that in most cases algorithms m
by CJefferson 12y ago
The biggest problem with destructive move in C++ (and one I personally think is unfixable, but I'm happy to be proved wrong), is that in most cases algorithms must be sure to recreate any variable they are not responsible for, as it will be destroyed later. There isn't any way of checking if some memory has already been destroyed, and adding any kind of flag just gets us back to the same position really. In particular I tried writing an exception safe std::sort (so make sure when std::sort exits all variables are reconsructed again), and it is an extremely difficult undertaking.
In general I find the lack of destructive move isn't a serious problem -- designing variables so their 'default state' is very cheap to construct isn't usually a major cost.