Reputation: 13908
In studying rvalues and rvalue references, I've been pointed to the excellent posting https://stackoverflow.com/a/11540204/368896, in which appears the following table:
lvalue const lvalue rvalue const rvalue
---------------------------------------------------------
X& yes
const X& yes yes yes yes
X&& yes
const X&& yes yes
Note that the table indicates that an rvalue cannot bind to a non-const lvalue reference.
However, in VS2010 I seem to be able to do so:
class A
{};
int main()
{
A & a = A(); // Binding an rvalue to a non-const lvalue reference?
}
Where is my misunderstanding?
Upvotes: 2
Views: 802
Reputation: 477060
This is a compiler "extension" (or "bug", depending on your perspective) of the Microsoft compiler. C++ only allows non-const binding of an lvalue to a non-const lvalue reference.
Upvotes: 3