3 ms·
Well, of course accessing the value of fh after foo would be fatal. But how would you then sort a container of moveable-only objects? An object should be acces
by meetingcpp 12y ago
Well, of course accessing the value of fh after foo would be fatal.
But how would you then sort a container of moveable-only objects?
An object should be accessible for reassigning a value after its move, as its often needed for algorithms, thats exactly why the C++ Standard mandates this. Move does really only make sense if the class holds a moveable allocation, such as a container, array etc., which makes copying expensive.
- dbaupp 12y ago> An object should be accessible for reassigning a value after its move, as its often needed for algorithms, thats exactly why the C++ Standard mandates this. The same is true in Rust. A moved-from value can be reassigned, but cannot be used (compile enforced) until it is reassigned. :)