From what I\'ve read and seen you cannot bind an expression that is an rvalue to an lvalue reference. What I have seen however is that you can bind an rvalue to an rvalue refere
When you call foo(1)
, a temporary int
equal to 1
is created, and int&& a
is bound to it. You can freely change it. The same way you can write int&& a = 1;
. a
itself is an lvalue, so you can bind lvalue reference to it.
You may read a great article Universal References by Scott Meyers which explains rvalue and lvalue references in detail.