What this C++ rvalue-reference question tests
This is a medium-difficulty question that probes your understanding of rvalue references and move semantics in C++. It asks you to trace through a code snippet and predict its output—a skill that separates candidates who have internalized modern C++ from those who only recognize the syntax.
To answer correctly, you need to understand when rvalue references bind, how move constructors and move assignment operators are invoked, and the subtle rules governing temporary lifetimes and reference collapsing. Interviewers use questions like this to gauge whether you can reason about resource ownership and object lifecycle in systems where performance matters.
- Rvalue references and move semantics
- Reference collapsing and perfect forwarding
- Constructor and assignment operator overload resolution
- Temporary object lifetimes