Let’s take a closer look at the code above. We will find that those both output as the “lvalue“. Because the rvalue passed into the function will own the name, then it could be got its address (Aka it’s a lvalue now.).
Reference Collapsing
Declaring the reference of a reference is illegal, but the compiler can generate a referenced reference during Template Instantiation. During Template Instantiation, Reference Collapsing can occur in this situation. If either of the references is an lvalue reference, the result will be an lvalue reference. If both are rvalue references, the result will be an rvalue reference.
Now, we attempt to encapsulate this functionality to a function. This function returns an lvalue reference when passed an lvalue reference, and returns an rvalue reference when passed an rvalue reference.