• <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.

            表達(dá)式不是左值就是右值。

            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)

            左值是指一個(gè)對象或者函數(shù)。某些右值(那些帶或不帶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. ] ]

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

            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. ]

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

            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.

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

            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)).

            對非引用類型的轉(zhuǎn)換表達(dá)式(包括使用函數(shù)式的記號進(jìn)行顯示創(chuàng)建)是右值,它將返回一個(gè)臨時(shí)對象。


            __________________
            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.

            有些表達(dá)式,比如調(diào)用構(gòu)造函數(shù)的表達(dá)式,以及調(diào)用返回類類型的函數(shù)的表達(dá)式,它們也是對象,且可以對它們調(diào)用成員函數(shù),但這種表達(dá)式不是左值。

            ____________________________________華麗的分頁符____________________________________

             

            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.

            如果在一個(gè)需要右值的場合出現(xiàn)了左值,這個(gè)左值將被轉(zhuǎn)換成右值。
            見 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 中關(guān)于引用的初始化和關(guān)于臨時(shí)對象的討論,也指出了左右值在其他重要場合的行為。

            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. ]

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

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

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

            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.

            指向一個(gè)不完整類型的指針可能是可修改的。當(dāng)這個(gè)被指向的類型某時(shí)某刻成為完整類型后,這個(gè)指針?biāo)赶虻哪莻€(gè)對象也是可修改的。

            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 限定的表達(dá)式所對應(yīng)的對象不能(通過該表達(dá)式)被修改;除非這個(gè)對象是類類型并且含有 mutable 成員,此時(shí)該 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.

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

            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.

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

            ——對象的動態(tài)類型;
            ——CV 限定的對象動態(tài)類型;
            ——對象的動態(tài)類型對應(yīng)的有符號或無符號類型;
            ——CV 限定的對象動態(tài)類型有符號或無符號類型;
            ——一個(gè)成員中含有聚合或者聯(lián)合類型的聚合或者聯(lián)合類型(包括遞歸形式的定義以及成員中有子聚合類型或者包含一個(gè)聯(lián)合)
            ——對象的動態(tài)類型的基類類型(可以被 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.
            給出這份列表的目的是指明一些特定情形,在這些情形下對象可能被重疊,但也有可能不是,我們無法預(yù)知。

            ____________________________________華麗的分隔符____________________________________

             

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

            posted on 2012-02-29 22:50 溪流 閱讀(1575) 評論(0)  編輯 收藏 引用 所屬分類: C++
            亚洲精品乱码久久久久久按摩| 99久久精品毛片免费播放| 国内精品伊人久久久久网站| 久久精品一区二区影院 | 国产精品青草久久久久婷婷| 久久国产精品久久精品国产| 久久国产乱子伦精品免费强| 久久性精品| 久久久精品一区二区三区| 欧美久久亚洲精品| 久久久久亚洲AV无码永不| 国产精品嫩草影院久久| 国产精品丝袜久久久久久不卡| 亚洲国产成人久久综合野外| 国产精品久久久久久影院| 日韩美女18网站久久精品| 潮喷大喷水系列无码久久精品| 久久国内免费视频| 欧美亚洲国产精品久久蜜芽| 午夜不卡久久精品无码免费 | 国产亚洲精午夜久久久久久| 色妞色综合久久夜夜| 久久人妻少妇嫩草AV无码蜜桃| 99国产欧美久久久精品蜜芽 | 国产精品久久影院| 久久久亚洲裙底偷窥综合 | 精品伊人久久大线蕉色首页| 久久久久97国产精华液好用吗| 色综合久久综精品| 精品熟女少妇a∨免费久久| 99久久综合国产精品免费| 久久精品国产99国产精品| 久久国产精品99精品国产987| 久久久久久亚洲精品成人| 亚洲乱码中文字幕久久孕妇黑人| 亚洲精品乱码久久久久久蜜桃| 久久精品亚洲男人的天堂| 日批日出水久久亚洲精品tv| 久久激情五月丁香伊人| 久久精品18| 久久婷婷国产剧情内射白浆|