• <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ù)傳遞給 const T& 編譯報錯

            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 閱讀(604) 評論(0)  編輯 收藏 引用


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


            導(dǎo)航

            統(tǒng)計

            常用鏈接

            留言簿

            隨筆分類(23)

            隨筆檔案(26)

            文章分類(1)

            文章檔案(1)

            csdn

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久亚洲AV成人网人人网站| 一本久道久久综合狠狠躁AV| 久久久久亚洲av无码专区喷水 | 亚洲国产精品久久久久网站| 国产精品一区二区久久精品无码| 狠狠色婷婷久久一区二区| 成人资源影音先锋久久资源网| 久久精品国产精品亚洲艾草网美妙| 伊人久久无码精品中文字幕| 久久免费视频网站| 中文字幕无码精品亚洲资源网久久| 国产免费久久精品丫丫| 久久久无码精品亚洲日韩按摩| 久久久久久久国产免费看| 2021精品国产综合久久| 国产精品亚洲综合久久| 26uuu久久五月天| 久久国产精品久久精品国产| 久久精品人妻中文系列| 中文字幕精品久久久久人妻| 国产成人精品久久亚洲高清不卡| 久久99精品久久久久久久久久| 久久AV高潮AV无码AV| 国产精品久久婷婷六月丁香| 久久夜色精品国产www| 国产99久久久久久免费看| 亚洲国产精久久久久久久| 精品久久久噜噜噜久久久| 国产美女久久精品香蕉69| 日日噜噜夜夜狠狠久久丁香五月| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 色欲综合久久中文字幕网| 久久青青草视频| 色综合久久88色综合天天 | 久久久久这里只有精品| 色综合久久88色综合天天 | 久久大香萑太香蕉av| 亚洲欧美日韩久久精品第一区| 色偷偷88888欧美精品久久久 | 久久99精品免费一区二区| 久久一区二区三区99|