Originally Posted by
CornedBee
Another special case, the reasoning behind which I don't know. The rule is:
If a reference is initialized with a temporary object, the lifetime of that temporary is extended to the lifetime of the reference.
That rule only applies if it is a const reference. You can't extend the lifetime of a temporary by using a non-const reference.
I was thinking of this, but as George reminds me, that is not the whole picture of what is an lvalue.:
e.g.
Code:
int val = 42;
int &ref = val;
const int &cref = val;
ref = 6; // fine
cref = 7; // illegal
Yes for #3 I knew what you meant George2, I was being pedantic