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

            小步慢跑

             

            GCC4.1.2 中 臨時(shí)對(duì)象作為參數(shù)傳遞給 const T& 編譯報(bào)錯(cuò)

            Copy constructor access check while initializing a reference.

            Consider this code:

            class A 
            {
            public:
              A();
            
            private:
              A(const A&);   // private copy ctor
            };
            
            A makeA(void);
            void foo(const A&);
            
            void bar(void)
            {
              foo(A());       // error, copy ctor is not accessible
              foo(makeA());   // error, copy ctor is not accessible
            
              A a1;
              foo(a1);        // OK, a1 is a lvalue
            }

            Starting with GCC 3.4.0, binding an rvalue to a const reference requires an accessible copy constructor. This might be surprising at first sight, especially since most popular compilers do not correctly implement this rule.

            The C++ Standard says that a temporary object should be created in this context and its contents filled with a copy of the object we are trying to bind to the reference; it also says that the temporary copy can be elided, but the semantic constraints (eg. accessibility) of the copy constructor still have to be checked.

            For further information, you can consult the following paragraphs of the C++ standard: [dcl.init.ref]/5, bullet 2, sub-bullet 1, and [class.temporary]/2.

            Starting with GCC 4.3.0, GCC no longer gives an error for this case. This change is based on the intent of the C++ language committee. As of 2010-05-28, the final proposed draft of the C++0x standard permits this code without error.

            posted on 2013-10-30 16:38 zaccheo 閱讀(598) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿

            隨筆分類(23)

            隨筆檔案(26)

            文章分類(1)

            文章檔案(1)

            csdn

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久亚洲私人国产精品| 久久免费小视频| 久久久91人妻无码精品蜜桃HD| 久久精品国产亚洲沈樵| www亚洲欲色成人久久精品| 欧美日韩成人精品久久久免费看| 欧美精品丝袜久久久中文字幕| 久久综合偷偷噜噜噜色| 国产美女亚洲精品久久久综合| 国产午夜福利精品久久2021| 国产亚州精品女人久久久久久 | 久久99热这里只有精品国产| 亚洲va久久久噜噜噜久久男同| 国产精品久久久久影视不卡| 久久久久久亚洲精品不卡| 国产成人精品综合久久久| 99久久国产亚洲高清观看2024| 色婷婷久久综合中文久久一本| 国内精品伊人久久久久av一坑| 色诱久久av| 国内精品久久久久久久影视麻豆| 午夜久久久久久禁播电影| 思思久久99热免费精品6| 国产亚洲色婷婷久久99精品| 一97日本道伊人久久综合影院| 久久久国产精品网站| 亚洲精品乱码久久久久久蜜桃不卡| 国内精品免费久久影院| 99久久国产综合精品麻豆| 波多野结衣久久精品| 久久九色综合九色99伊人| 色综合色天天久久婷婷基地| 午夜精品久久久久久久| 久久久久久久精品成人热色戒| 久久精品国产精品亚洲| 91精品国产高清久久久久久国产嫩草| 色偷偷久久一区二区三区| 无码人妻久久久一区二区三区| 久久天天躁夜夜躁狠狠| 一本一本久久a久久精品综合麻豆| 久久久久亚洲AV综合波多野结衣|