Implementing std::move for C++ rvalue reference semantics
This hard C++ problem tests your understanding of rvalue references, template specialization, and how the standard library enables move semantics at a fundamental level. Quant firms use it to verify that candidates grasp the distinction between lvalue and rvalue categories, and can implement a core language feature correctly.
The challenge here is subtle: std::move does not actually move anything. Instead, it converts an lvalue into an rvalue reference, signalling to the compiler that the object's resources may be stolen. Your implementation must handle multiple input categories—lvalues, rvalues, const references, and arrays—using template parameter deduction and specialization. Non-copyable types require special care, since the compiler will reject code paths that attempt to copy when only move construction is available.
- Rvalue references and reference collapsing rules
- Template parameter deduction for lvalue and rvalue inputs
- Overload resolution and const-correctness
- Array decay and decay traits