3 ms·
C++ move semantics was added to the existing standard library and class syntax in a way that avoided breaking old code. The language added "move constructor" co
by gary_0 3y ago
C++ move semantics was added to the existing standard library and class syntax in a way that avoided breaking old code. The language added "move constructor" conventions and the like, rather than making more drastic internal changes.
So moving from a std::string variable means it's still a valid object, only its internal state is now owned by someone else, and the std::string is required to now be in an "empty" (but still valid) state. Most of the "moving" is actually handled by extra code in std::string rather than the core language having rules for how the underlying bytes are moved around, because the core language wasn't changed that much.