What this C++ r-value semantics question tests
This is a hard language-knowledge question that probes deep understanding of C++ move semantics and r-value references. It rewards candidates who can trace through reference binding rules, temporary object lifetimes, and the distinction between l-values and r-values without relying on guesswork.
To solve problems in this area, you need to reason carefully about which overloads are selected, when temporaries are created and destroyed, and how std::move and forwarding affect the behaviour of code. Firms use these questions to filter for candidates with solid mental models of modern C++, especially those working on performance-critical systems where move semantics and perfect forwarding are essential.
- L-value vs. r-value references and their binding rules
- Temporary object lifetimes and the return value optimisation
- Overload resolution and reference collapsing
- Move constructors and move assignment operators