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

            導航

            統(tǒng)計

            常用鏈接

            留言簿

            隨筆分類(23)

            隨筆檔案(26)

            文章分類(1)

            文章檔案(1)

            csdn

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            91麻豆精品国产91久久久久久 | 久久亚洲春色中文字幕久久久| 日韩一区二区三区视频久久| 久久久久青草线蕉综合超碰 | 亚洲va久久久噜噜噜久久天堂| 久久精品亚洲AV久久久无码| 无遮挡粉嫩小泬久久久久久久 | 久久99精品久久久久婷婷| 国产午夜久久影院| 久久狠狠爱亚洲综合影院| 色综合色天天久久婷婷基地| 少妇熟女久久综合网色欲| 99久久综合狠狠综合久久止| 亚洲美日韩Av中文字幕无码久久久妻妇| 无码人妻久久一区二区三区免费| 99久久精品免费看国产免费| 日韩人妻无码一区二区三区久久99| 国产成人精品久久一区二区三区| 人妻丰满?V无码久久不卡| 99久久99这里只有免费费精品| 久久综合视频网站| 伊人丁香狠狠色综合久久| 欧美黑人激情性久久| 欧美精品九九99久久在观看| 亚洲va久久久久| 91精品国产综合久久香蕉| 久久精品国产亚洲精品2020| 日韩美女18网站久久精品| 丰满少妇人妻久久久久久4| 久久人人爽人人爽人人AV| 亚洲精品高清国产一线久久| 亚州日韩精品专区久久久| 久久午夜综合久久| 久久本道久久综合伊人| 久久国产乱子伦精品免费午夜| 久久精品国产亚洲麻豆| 精品国产福利久久久| 2021国产成人精品久久| 精品国产综合区久久久久久| 精品免费久久久久国产一区| 久久久久人妻精品一区三寸蜜桃|