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 reference and since a named rvalue reference is inherently an lvalue, you can bind it to an lvalue reference. What is the reason behind disallowing binding an rvalue to an lvalue reference. Is it for optimization purposes?
Take this example:
#include <iostream>
using std::cout;
void bar ( int& b ) {
cout << "bar " << b << "\n";
b = 3;
}
void foo ( int&& a ) {
cout << a << "\n";
bar(a);
cout << a << "\n";
}
int main ( int argc, char ** argv ) {
foo(1);
}