不理解 c++的value categories
本帖最后由 neodreamerus 于 2016-07-14 10:02 编辑lvalue 和 rvalue本来是理解的。
但是下面的解释中lvalue 和 rvalue 是借助 glvalue prvalue xvalue这几个概念解释的,
反而弄不懂了。
哪位大神给点拨我一下,谢谢
摘自 http://en.cppreference.com/w/cpp/language/value_category
Value categories
C++C++ languageExpressions
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. 彻底懵逼了。。。。
页:
[1]