← Move Semantics: rvalue References & std::move

Trace: Copy vs. Move

hard

Create c as a copy of a, then d by moving from b – in that order. You’re not writing any print statements yourself; Buffer’s constructors already announce which one ran, so the expected output is a direct trace of which constructor gets selected for each line.

The distinction is entirely about how you write each initialization, not about Buffer’s data: Buffer c = a; copies because a is a plain named variable (an lvalue) sitting on the right of =; wrapping b in std::move is what makes the second line resolve to the move constructor instead of the copy constructor it would otherwise select.

Your solution

"Run" uses the sample stdin (none). "Submit" checks your code against all 1 test case.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution