• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-90  評論-947  文章-0  trackbacks-0

            3.10 Lvalues and rvalues [basic.lval]

            左值和右值

            1 Every expression is either an lvalue or an rvalue.

            表達式不是左值就是右值。

            2 An lvalue refers to an object or function. Some rvalue expressions—those of class or cv-qualified class type—also refer to objects. 47)

            左值是指一個對象或者函數。某些右值(那些帶或不帶cv限定符的類類型)也是對象。

            3 [Note:
            some built-in operators and function calls yield lvalues. [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 function
            int& f();
            yields an lvalue, so the call f() is an lvalue expression. ] ]

            [注意:某些內置運算符以及一些函數調用會返回左值。[例1:如果 E 是一個指針類型的表達式,那么 *E 是一個左值表達式,指示指針 E 所指向的那個對象或者函數。例2:函數
            int& f();
            返回左值,所以函數調用 f() 是一個左值表達式。] ]

            4 [Note: some built-in operators expect lvalue operands. [Example: built-in assignment operators all expect their left hand operands to be lvalues. ] Other built-in operators yield rvalues, and some expect them. [Example: the unary and binary + operators expect rvalue arguments and yield rvalue results. ] The discussion of each built-in operator in clause 5 indicates whether it expects lvalue operands and whether it yields an lvalue. ]

            [注意:某些內置運算符需要左值操作數。[例:所有內置的賦值運算符的左操作數都必須是左值。] 有些內置運算符會返回右值結果,有些會需要右值操作數。[例:一元運算符“+”和二元運算符“+”都需要右值操作數,并且返回右值結果。] 我們在條款 5 中會對所有內置運算符進行討論,指出它們的操作數和返回結果是左值還是右值。]

            5 The result of calling a function that does not return a reference is an rvalue. User defined operators are functions, and whether such operators expect or yield lvalues is determined by their parameter and return
            types.

            調用返回值為非引用類型的函數,結果是右值。用戶自定義的運算符也是函數,這些運算符的操作數以及結果是左值還是右值,取決于(運算符重載)函數的參數和返回值類型。

            6 An expression which holds a temporary object resulting from a cast to a nonreference type is an rvalue (this includes the explicit creation of an object using functional notation (5.2.3)).

            對非引用類型的轉換表達式(包括使用函數式的記號進行顯示創建)是右值,它將返回一個臨時對象。


            __________________
            47) Expressions such as invocations of constructors and of functions that return a class type refer to objects, and the implementation can invoke a member function upon such objects, but the expressions are not lvalues.

            有些表達式,比如調用構造函數的表達式,以及調用返回類類型的函數的表達式,它們也是對象,且可以對它們調用成員函數,但這種表達式不是左值。

            ____________________________________華麗的分頁符____________________________________

             

            7 Whenever an lvalue appears in a context where an rvalue is expected, the lvalue is converted to an rvalue; see 4.1, 4.2, and 4.3.

            如果在一個需要右值的場合出現了左值,這個左值將被轉換成右值。
            見 4.1、4.2、4.3。

            8 The discussion of reference initialization in 8.5.3 and of temporaries in 12.2 indicates the behavior of lvalues and rvalues in other significant contexts.

            12.2 中關于引用的初始化和關于臨時對象的討論,也指出了左右值在其他重要場合的行為。

            9 Class rvalues can have cv-qualified types; non-class rvalues always have cv-unqualified types. Rvalues shall always have complete types or the void type; in addition to these types, lvalues can also have incomplete types.

            類類型的右值可以具有 cv 限定符;非類類型的右值不能被 cv 限定符修飾。右值通常是完整類型或者 void 類型,而對于左值來說,除了完整類型和 void 類型外,還可以是不完整類型。

            10 An lvalue for an object is necessary in order to modify the object except that an rvalue of class type can also be used to modify its referent under certain circumstances. [Example: a member function called for an object (9.3) can modify the object. ]

            通常情況下,如果要修改一個對象,它必須是左值。但在某些特定的場合,右值形式的類對象也可以被修改。[例:調用一個對象的成員函數(9.3),可以修改對象本身。]

            11 Functions cannot be modified, but pointers to functions can be modifiable.

            函數(對象)不能(在運行時)被修改,但是函數指針可以。

            12 A pointer to an incomplete type can be modifiable. At some point in the program when the pointed to type is complete, the object at which the pointer points can also be modified.

            指向一個不完整類型的指針可能是可修改的。當這個被指向的類型某時某刻成為完整類型后,這個指針所指向的那個對象也是可修改的。

            13 The referent of a const-qualified expression shall not be modified (through that expression), except that if it is of class type and has a mutable component, that component can be modified (7.1.5.1).

            被 const 限定的表達式所對應的對象不能(通過該表達式)被修改;除非這個對象是類類型并且含有 mutable 成員,此時該 mutable 成員可以被修改。

            14 If an expression can be used to modify the object to which it refers, the expression is called modifiable. A program that attempts to modify an object through a nonmodifiable lvalue or rvalue expression is illformed.

            如果一個表達式可以被用來修改此表達式對應的對象,那么這個表達式被稱為可修改的。企圖通過一個不可修改的左值者右值表達式去修改一個對象,是非法的。

            15 If a program attempts to access the stored value of an object through an lvalue of other than one of the following types the behavior is undefined 48):
            — the dynamic type of the object,
            — a cv-qualified version of the dynamic type of the object,
            — a type that is the signed or unsigned type corresponding to the dynamic type of the object,
            — a type that is the signed or unsigned type corresponding to a cv-qualified version of the dynamic type of
            the object,
            — an aggregate or union type that includes one of the aforementioned types among its members (including,
            recursively, a member of a subaggregate or contained union),
            — a type that is a (possibly cv-qualified) base class type of the dynamic type of the object,
            — a char or unsigned char type.

            如果程序通過下列類型之外類型的左值訪問一個對象的值,其行為是未定義的:

            ——對象的動態類型;
            ——CV 限定的對象動態類型;
            ——對象的動態類型對應的有符號或無符號類型;
            ——CV 限定的對象動態類型有符號或無符號類型;
            ——一個成員中含有聚合或者聯合類型的聚合或者聯合類型(包括遞歸形式的定義以及成員中有子聚合類型或者包含一個聯合)
            ——對象的動態類型的基類類型(可以被 cv 限定符修飾)
            ——char 或 unsigned char 類型


            __________________
            48) The intent of this list is to specify those circumstances in which an object may or may not be aliased.
            給出這份列表的目的是指明一些特定情形,在這些情形下對象可能被重疊,但也有可能不是,我們無法預知。

            ____________________________________華麗的分隔符____________________________________

             

            以上,求指正,包括理解誤區和語言組織不合理的,歡迎指出~ ^_^

            posted on 2012-02-29 22:50 溪流 閱讀(1576) 評論(0)  編輯 收藏 引用 所屬分類: C++
            久久久久中文字幕| 久久99久久99小草精品免视看| 97久久超碰国产精品旧版| AV狠狠色丁香婷婷综合久久| 国产午夜久久影院| 久久亚洲国产成人影院| 午夜精品久久久久久毛片| 品成人欧美大片久久国产欧美...| 99久久www免费人成精品| 久久精品国产亚洲av麻豆蜜芽 | 久久久久se色偷偷亚洲精品av | 97久久国产露脸精品国产| 久久超碰97人人做人人爱| 久久久亚洲精品蜜桃臀| 久久精品国产亚洲av日韩| 婷婷久久综合九色综合绿巨人| 国产精品久久久久无码av| 国产aⅴ激情无码久久| 日日狠狠久久偷偷色综合96蜜桃| 久久99国产综合精品女同| 久久亚洲精品成人无码网站| 国产精品免费看久久久香蕉| 久久国产亚洲高清观看| 久久热这里只有精品在线观看| 久久久久久无码国产精品中文字幕| 久久天天躁狠狠躁夜夜网站| 一本久道久久综合狠狠爱| 亚洲欧美成人久久综合中文网 | 久久久久亚洲AV无码去区首| 久久免费精品视频| 久久久女人与动物群交毛片| 精品人妻伦九区久久AAA片69| 亚洲国产视频久久| 婷婷久久五月天| 日韩人妻无码一区二区三区久久99| 久久精品不卡| 亚洲午夜精品久久久久久app| 久久笫一福利免费导航 | 狠狠色丁香久久婷婷综合蜜芽五月| 色偷偷88欧美精品久久久 | 久久午夜福利无码1000合集|