I guess this document might serve as a not so short introduction : n3055
The whole massacre began with the move semantics. Once we have expressions that can be moved and not copied, suddenly easy to grasp rules demanded distinction between expressions that can be moved, and in which direction.
From what I guess based on the draft, the r/l value distinction stays the same, only in the context of moving things get messy.
Are they needed? Probably not if we wish to forfeit the new features. But to allow better optimization we should probably embrace them.
Quoting n3055:
- An lvalue (so-called, historically,
because lvalues could appear on the
left-hand side of an assignment
expression) designates a function or
an object. [Example: If
E
is an
expression of pointer type, then *E
is an lvalue expression referring to
the object or function to which E
points. As another example, the
result of calling a function whose
return type is an lvalue reference is
an lvalue.]
- An xvalue (an
“eXpiring” value) also refers to an
object, usually near the end of its
lifetime (so that its resources may
be moved, for example). An xvalue is
the result of certain kinds of
expressions involving rvalue
references. [Example: The
result of calling a function whose
return type is an rvalue reference is
an xvalue.]
- A glvalue (“generalized” lvalue) is an lvalue
or an xvalue.
- An rvalue (so-called,
historically, because rvalues could
appear on the right-hand side of an
assignment expression) is an xvalue,
a temporary object or
subobject thereof, or a value that is
not associated with an object.
- A
prvalue (“pure” rvalue) is an rvalue
that is not an xvalue. [Example: The
result of calling a function whose
return type is not a reference is a
prvalue]
The document in question is a great reference for this question, because it shows the exact changes in the standard that have happened as a result of the introduction of the new nomenclature.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…