Value categories

来自cppreference.com

 
 
C + +語言
大會的主題
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
流量控制
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
條件執行語句
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
迭代語句
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
跳轉語句
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
功能
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
函數聲明
lambda函數的聲明
函數模板
的歷史。內嵌說明
異常規範 (過時了)
noexcept說明 (C++11)
例外
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
命名空間
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
類型
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier (C++11)
規範
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
CV符
存儲時間說明符
constexpr說明 (C++11)
汽車符 (C++11)
alignas說明 (C++11)
初始化
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
布爾文字
nullptr (C++11)
用戶定義的 (C++11)
表達式
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
價值類型
為了評價
另一種表示形式
實用工具
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
類型
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
聲明類型別名 (C++11)
屬性 (C++11)
施放
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
隱式轉換
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-風格和功能轉換
內存分配
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
類特定的功能特性
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
虛函數
覆蓋說明 (C++11)
最後說明 (C++11)
明確的 (C++11)
靜態的
特殊的成員函數
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
模板
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
類模板
函數模板
模板特化
參數包 (C++11)
雜項
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
內聯彙編
 
當一個C + +表達式(操作符與它的參數)進行評估,其結果是一些非引用類型的值。每個表達式的主要價值類別的一個.
Original:
When a C++ expression (an operator with its arguments) is evaluated, it results in a value of some non-reference type. Each expression belongs to exactly one of the primary value categories.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目錄

[编辑] 主要類別

[编辑] 左值

「左值」是一個表達式,用於標識一個非臨時對象或一個非成員函數.
Original:
An lvalue is an expression that identifies a non-temporary object or a non-member function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
下面的表達式是左值
Original:
The following expressions are lvalues:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 範圍內的對象或函數的名稱,無論類型,如std::cinstd::endl。即使對象的類型是右值引用,表達它的名字是一個左值表達式.
    Original:
    The name of an object or function in scope, regardless of type, such as std::cin or std::endl. Even if the object's type is rvalue reference, the expression consisting of its name is an lvalue expression.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 函數調用操作符表達式的功能或操作者的返回類型是一個左值引用,如std::getline(cin, str)cout << 1++n*p
    Original:
    Function call or operator expression if the function's or operator's return type is an lvalue reference, such as std::getline(cin, str) or cout << 1 or or ++n or *p
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 強制轉換表達式的左值的引用類型.
    Original:
    Cast expression to lvalue reference type.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 如果函數的返回類型的函數調用表達式的右值引用功能類型(罕見)
    Original:
    Function call expression if the function's return type is rvalue reference to function type (rare)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • CAST表達式的右值引用的功能.
    Original:
    Cast expression to rvalue reference to function.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
屬性
Original:
Properties:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 同glvalue(如下圖)
    Original:
    Same as glvalue (below)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 一個左值的地址可以採取:&++i&std::endl是有效的表達式.
    Original:
    Address of an lvalue may be taken: &++i and &std::endl are valid expressions.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 修改的左值,可以使用內置的賦值運算符的第一個參數(左).
    Original:
    A modifiable lvalue may be used as the first (left) argument of the built-in assignment operator.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 一個lvalue可用於初始化左值參考,這由表達式識別的對象的一個​​新的名字而相關聯.
    Original:
    An lvalue may be used to 初始化左值參考; this associates a new name with the object identified by the expression.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[编辑] 右值NJ/ prvalueNJ

A「prvalue」是一個表達式,用於標識一個臨時對象(或子對象除外),或不與任何對象關聯的值.
Original:
A prvalue is an expression that identifies a temporary object (or a subobject thereof) or is a value not associated with any object.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
下面的表達式prvalues​​
Original:
The following expressions are prvalues:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 文字,如42truenullptr.
    Original:
    Literal, such as 42 or true or nullptr.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 如果函數調用/操作符表達式的功能或操作人員的返回類型是不是一個引用,如str.substr(1, 2)2+2
    Original:
    Function call/operator expression if the function's or the operator's return type is not a reference, such as str.substr(1, 2) or 2+2
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • CAST表達式引用類型以外的其他任何類型.
    Original:
    Cast expression to any type other than reference type.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Lambda表達式,如 [](int x){return x*x;}
    Original:
    Lambda expressions, such as  [](int x){return x*x;}
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
屬性
Original:
Properties:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 同右值(如下圖)
    Original:
    Same as rvalue (below)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 一個prvalue不能是多態對象的動態類型,它確定類型的表達式.
    Original:
    a prvalue cannot be polymorphic: the dynamic type of the object it identifies is always the type of the expression.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 不能被const限定非類prvalue的.
    Original:
    a non-class prvalue cannot be const-qualified.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[编辑] xvalueNJ

一個 xvalue「,用於標識一個」屆滿「對象的,即,從可移動的對象,該對象是一個表達式。可能是一個無名的臨時標識的對象由一個xvalue的表達,它可能是一個命名對象,範圍,或任何其他類型的對象,但如果作為函數的參數,xvalue將始終綁定到右值引用過載,如果有的話.
Original:
An xvalue is an expression that identifies an "expiring" object, that is, the object that may be moved from. The object identified by an xvalue expression may be a nameless temporary, it may be a named object in scope, or any other kind of object, but if used as a function argument, xvalue will always bind to the rvalue reference overload if available.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
只有以下的表達式是xvalues​​:
Original:
Only the following expressions are xvalues:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 一個函數調用表達式,如果函數的返回類型是一個右值引用的對象類型,如std::move(val)
    Original:
    A function call expression, if the function's return type is an rvalue reference to object type, such as std::move(val)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 一個右值引用的對象類型強制轉換表達式,如static_cast<T&&>(val)(T&&)val
    Original:
    A cast expression to an rvalue reference to object type, such as static_cast<T&&>(val) or (T&&)val
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 類的非靜態成員訪問表達式,其中的對象表達式的值為xValue
    Original:
    a non-static class member access expression, in which the object expression is an xvalue
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 在第一個操作數的指針成員表達是xValue和第二個操作數是一個指向數據成員的指針.
    Original:
    A pointer-to-member expression in which the first operand is an xvalue and the second operand is a pointer to data member.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
屬性
Original:
Properties:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 同右值(如下圖)
    Original:
    Same as rvalue (below)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 同glvalue(如下圖)
    Original:
    Same as glvalue (below)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
像prvalues​​,xvalues​​綁定到右值引用,,但不像prvalues​​,值為xValue,可能是多態的,非類值為xValue可能是合格的CV-.
Original:
Like prvalues, xvalues bind to rvalue references, but unlike prvalues, an xvalue may be polymorphic, and a non-class xvalue may be cv-qualified.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 混合類

[编辑] glvalueNJ

一個glvalue是一個表達式,它是一個左值,或一個xvalue的.
Original:
A glvalue is an expression that is either an lvalue or an xvalue.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
屬性
Original:
Properties:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 一個glvalue可以隱式轉換為左值,右值,數組與指針,或函數指針隱式轉換prvalue.
    Original:
    A glvalue may be implicitly converted to prvalue with lvalue-to-rvalue, array-to-pointer, or function-to-pointer 隱式轉換.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 一個glvalue可能是多態的動態類型的對象,它標識不一定是靜態類型的表達式.
    Original:
    A glvalue may be polymorphic: the dynamic type of the object it identifies is not necessarily the static type of the expression.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[编辑] 右值NJ

右邊的值可以是一個表達式,它可以是一個prvalue或值為xValue.
Original:
An rvalue is an expression that is either a prvalue or an xvalue.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
屬性(注意,這些適用於都的xvalues​​和prvalues​​,這意味著它們適用於前C + +11的右值以及)
Original:
Properties (note, these apply to both xvalues and prvalues, which means they apply to the pre-C++11 rvalues as well)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 一個rvalue的地址可能不會採取&i++&42&std::move(val)是無效的.....
    Original:
    Address of an rvalue may not be taken: &i++ and &42 and &std::move(val) are invalid.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 可以使用一個rvalue初始化一個常量左值引用,在這種情況下,由右值標識的對象的壽命延長,直到參考端的範圍.
    Original:
    An rvalue may be used to 初始化一個常量左值引用, in which case the lifetime of the object identified by the rvalue is extended until the scope of the reference ends.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 可以使用一個rvalue初始化一個右值引用,在這種情況下,由右值標識的對象的壽命延長,直到參考端的範圍.
    Original:
    An rvalue may be used to 初始化一個右值引用, in which case the lifetime of the object identified by the rvalue is extended until the scope of the reference ends.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 當作為函數的參數時,兩個重載的函數的情況下,一個右值引用參數和其他左值const參數,右值綁定到右值引用過載(因此,如果複製和移動的構造是,右值參數調用移動的構造函數,同樣的複製和移動賦值運算符).
    Original:
    When used as a function argument and when two overloads of the function are available, one taking rvalue reference parameter and the other taking lvalue reference to const parameter, rvalues bind to the rvalue reference overload (thus, if both copy and move constructors are available, rvalue arguments invoke the 移動的構造函數, and likewise with copy and move assignment operators).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[编辑] 特殊類別

[编辑] 的成員函數調用之前

表達obj.*mfpptr->*mfp地方mfp是一個指向成員函數的指針,分類prvalue的表達,但他們可以不被使用,以初始化引用,作為函數的參數,或為任何目的,在所有,除非在左側的參數的函數,調用表達式,例如: (pobj->*ptr)(args).
Original:
The expressions obj.*mfp and ptr->*mfp where mfp is a pointer to member function, are classified as prvalue expressions, but they cannot be used to initialize references, as function arguments, or for any purpose at all, except as the left-hand argument of a function call expression, e.g. (pobj->*ptr)(args).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 無效的表達

函數調用表達式返回void,投的表達式來void,和扔表達式被列為prvalue的表達,但它們不能被用來初始化引用或作為函數的參數。它們可以被用來在一個廢棄價值的情況下(例如,在一個屬於自己的行,左邊的參數的逗號操作符等),並在return聲明一個函數返回void。拋出表達式(但並非其他的空隙prvalues​​)此外,也可以使用作為第二個和第三個操作數的條件運算符?.
Original:
Function call expressions returning void, cast expressions to void, and throw-expressions are classified as prvalue expressions, but they cannot be used to initialize references or as function arguments. They can be used in a discarded-value context (e.g. on a line of its own, as the left argument of the comma operator, etc) and in the return statement in a function returning void. In addition, throw-expressions (but not other void prvalues) may be used as the second and the third operands of the 條件運算符?.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.