Hi
I was trying to understand glvalues, rvalues, lvalues, xvalues and prvalues in c++11. But I figured that I do not have a basic understanding of what lvalues and rvalues meant before c++11 (i.e. in c++03 and even before that).
Also, I tried, but I could not get my hands on a c++03 standard.
Caution: long post.
What I have understood until now (or so I believe), please correct me wherever I am wrong:
- "An object is a manipulable region of storage; an lvalue is an expression referring to an object..."
- we can have non modifiable lvalues too. (const qualified lvalues are non modifiable) [an expression is modifiable, if through it we can modify the object it is referring to]
- "Conceptually, an rvalue is just a value; it doesn't refer to an object. In practice, it's not that an rvalue can't refer to an object. It's just that an rvalue doesn't necessarily refer to an object."
- until now:
- modifiable lvalue - addressable + assignable
- non modifiable lvalue - addressable not assignable
- rvalue - neither addressable not assignable
- this only applies to rvalues of non-class types [Q1][Q2]
- I understand that one can modify rvalues of class type by calling their member functions.
- Example: http://ideone.com/GtaVpS
- and if you return a const rvalue of class-type you would not be able to modify it. because rvalues of class-type retain their cv qualifiers.
- Some where in the standard it must have been mentioned that non-class rvalues always are cv-unqualified, because it gets quoted a lot.
- Hence [Q3]
Questions:
[Q1] What are class-types and non-class types?
[Q2] What's so different in rvalues of class type when compared to non-class types.
[Q3] How does one modify a non-class type rvalue? If one cannot why did the need arose in the standard to specify that non-class rvalues are always cv-unqualified.