Reference collapsing
lastmod 2026-11-10created 2015-09-242 edits
Reference collapsing is the rule by which the C++ compiler merges a reference to a reference into a single reference when one arises through template deduction or a type alias. If either of the two references is an lvalue reference (&), the result is an lvalue reference; only when both are rvalue references (&&) is the result an rvalue reference. It is what makes it possible for forwarding references (universal references) and std::forward to implement perfect forwarding, which preserves the value category of an argument.