Why const int
is not an R-value in C++(11)? I thought that R-value was \'anything\' which cannot be on the left hand side and constants fulfil that
I thought that R-value was 'anything' which cannot be on the left hand side [of an assignment operaton]
That's the C++03 definition of rvalue
, and even then its a colloquialism and not universally true.
In C++11, the definitions for lvalue
and rvalue
have changed somewhat. The rules are complex, and individual situations are handled on a case-by-case basis in the Standard, but here is a general rule of thumb:
lvalue
lvalue
reference, that expression is an lvalue
rvalue
In your particular case, you can take the address of x
(eg, it "has a name") and it is therefore an lvalue.
You can read more about lvalues and rvalues in C++11 in two excellent articles: