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

            導航

            統(tǒng)計

            常用鏈接

            留言簿

            隨筆分類(23)

            隨筆檔案(26)

            文章分類(1)

            文章檔案(1)

            csdn

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            99热热久久这里只有精品68| 7国产欧美日韩综合天堂中文久久久久 | 久久人人爽人人爽人人片AV东京热| 国产激情久久久久影院老熟女免费| 久久综合亚洲色HEZYO国产| 久久久国产打桩机| 国产精品一久久香蕉国产线看| 国内精品久久久久久中文字幕| 亚洲国产成人精品女人久久久| 亚洲精品国产美女久久久| 四虎国产精品免费久久5151| 久久这里的只有是精品23| 激情伊人五月天久久综合 | 日韩欧美亚洲国产精品字幕久久久| 久久精品国产AV一区二区三区| 国产精品久久久久久一区二区三区| 久久精品国产亚洲Aⅴ香蕉| 精品国产乱码久久久久久人妻| 国产成人综合久久久久久| 老色鬼久久亚洲AV综合| 亚洲午夜久久久| 99久久99久久精品国产| 亚洲va中文字幕无码久久| 欧美日韩精品久久久免费观看| 国产成人综合久久综合| 一本久久a久久精品vr综合| 久久青青草原精品国产软件| 国产午夜久久影院| 欧洲人妻丰满av无码久久不卡| 久久精品国产亚洲av麻豆蜜芽| 久久久久99精品成人片牛牛影视| 97r久久精品国产99国产精| 久久精品国产亚洲AV麻豆网站 | 久久九色综合九色99伊人| 国产精品青草久久久久婷婷| 久久午夜无码鲁丝片| 伊人久久无码中文字幕| 精品久久人人爽天天玩人人妻 | 久久精品无码一区二区无码| 77777亚洲午夜久久多喷| 亚洲午夜久久久久妓女影院|