As a continuation of the question " Differences between Rvalue and Lvalue " and based on the question " What are rvalues, lvalues, xvalues, glvalues, and prvalues? ".
In C++03, an expression could be rvalue
or lvalue
.
As of C++11, three new categories were added, the full list of categories being:
rvalue
: Value of the right side (r
ightvalue
).lvalue
: Value of the left side (l
eftvalue
).xvalue
: Expiration value (ex
piringvalue
).glvalue
: Value of the generalized left-hand side ( generalized eftg
) .l
value
prvalue
: Value of the pure right hand side (p
urer
ightvalue
).
We have gone from two categories to five.
- What are these new categories of expressions?
- How are they related to the
rvalue
ylvalue
that existed before? - Are the
rvalue
ylvalue
's in C++03 the same as in C++11? - Why are these categories necessary?
Is the standards committee just trying to confuse us?
According to the C++ 1 standard (my translation):
This would answer us what these categories of expressions are and how they relate to each other. Regarding whether
lvalue
andrvalue
are the same in C++03 and C++11, we can say that they are not quite:The
lvalue
ones from C++03 keep the same category in C++11, while thervalue
ones from C++03 are now theprvalue
ones from C++11. In general we can say that theyrvalue
have evolved to take into account the semantics of movement , which also responds to why the new categorizations are necessary since without them, the semantics of movement would not be possible.1 That version of the standard was published at the end of March 2010.