Why rvalue References Variables are Not rvalue References
Consider two overloads of a function f:
void f(T&&&); // #1 void f(T&); // #2
In another function g:
void g(T&& t) { f(t); // calls #2 }
Why does the overload f(T&) get called despite the parameter t being an rvalue?
The Nature of rvalue References
Rvalue references are variables that can only bind to rvalues (objects without names). T&&t has a name, making it an lvalue.
Distinction between Type and Value
T&& is the type rvalue reference. An rvalue reference can bind only to rvalues, but it is otherwise an lvalue of reference type.
Special Cases
Rules Governing Rvalue References
The above is the detailed content of Why Doesn't `f(T&&)` Get Called When Passing an Rvalue Reference to It?. For more information, please follow other related articles on the PHP Chinese website!