I guess this document might serve as a not so short introduction : n3055
(我猜这个文档可能只是一个简短的介绍: 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.
(根据我对草案的猜测,r / l值的区别保持不变,只是在移动事物变得混乱的情况下。)
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 :
(引用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. ([示例:如果E
是指针类型的表达式,那么*E
是一个左值表达式,它引用E
指向的对象或函数。)
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).
(xvalue (“ eXpiring”值)也指对象,通常在其生命周期快要结束时(例如,可以移动其资源)。)
An xvalue is the result of certain kinds of expressions involving rvalue references. (xvalue是某些包含rvalue引用的表达式的结果。)
[Example: The result of calling a function whose return type is an rvalue reference is an xvalue.] ([示例:调用返回类型为rvalue引用的函数的结果为xvalue。)
- A glvalue (“generalized” lvalue) is an lvalue or an xvalue .
(甲glvalue(“广义”左值)是左值或x值 。)
- 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.
(一个右值 (所谓的,历史上,因为右值可能出现在赋值表达式的右侧)是一个x值,其临时对象或子对象或与对象不相关的值。)
- A prvalue (“pure” rvalue) is an rvalue that is not an xvalue.
(prvalue (“纯” rvalue)是不是xvalue的rvalue。)
[Example: The result of calling a function whose return type is not a reference is a prvalue] ([示例:调用返回类型不是引用的函数的结果是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.
(所讨论的文档对该问题提供了很好的参考,因为它显示了由于引入了新术语而导致的标准的确切变化。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…