Last Updated: May 17, 2026
The previous lesson introduced rvalue references and showed how move semantics avoid unnecessary copies. This chapter is about a related problem that move semantics alone can't solve: writing a generic function that takes arguments and hands them off to another function while preserving exactly what the caller passed, including whether each argument was an lvalue or rvalue, and whether it was const. The tool C++ gives you for that is std::forward, and the language feature that makes it work is the forwarding reference, T&& in a deduced context.