C++ Output Prediction Hard +35 XP
Move Semantics
After std::move, what is the state of s1?
C++Read-only
string s1 = "hello"; string s2 = move(s1); cout << s1.size();
What is the output?
Show answer and explanation
Answer: 0 (moved-from, empty)
std::move transfers ownership. s1 is left in a valid but unspecified state — typically empty for std::string.
Hint: After a move, the source is in a valid but unspecified state.
What this challenge tests
Output Prediction in C++: move-semantics, rvalue.