- 論壇徽章:
- 2
|
本帖最后由 neodreamerus 于 2016-07-14 10:02 編輯
lvalue 和 rvalue本來是理解的。
但是下面的解釋中l(wèi)value 和 rvalue 是借助 glvalue prvalue xvalue這幾個概念解釋的,
反而弄不懂了。
哪位大神給點撥我一下,謝謝
摘自 http://en.cppreference.com/w/cpp/language/value_category
Value categories
C++ C++ language Expressions
Each C++ expression (an operator with its operands, a literal, a variable name, etc.) is characterized by two independent properties: a type and a value category. Each expression has some non-reference type, and each expression belongs to exactly one of the three primary value categories: prvalue, xvalue, lvalue, defined as follows:
a glvalue is an expression whose evaluation determines the identity of an object, bit-field, or function
a prvalue is an expression whose evaluation either
computes the value of the operand of an operator (such prvalue has no result object), or
initializes an object or a bit-field (such prvalue is said to have a result object). All class and array prvalues have a result object even if it is discarded.
an xvalue is a glvalue that denotes an object or bit-field whose resources can be reused
an lvalue is a glvalue that is not an xvalue.
an rvalue is a prvalue or an xvalue. |
|