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

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            伊人色综合久久天天人手人婷| 久久精品无码一区二区WWW| 久久国产一区二区| 88久久精品无码一区二区毛片 | 精品久久人人妻人人做精品| 国产精品免费看久久久香蕉| 久久国产精品波多野结衣AV| 思思久久精品在热线热| 国产精品久久网| 亚洲成色WWW久久网站| 精品国产91久久久久久久a| 久久天天躁狠狠躁夜夜2020一| 久久99精品久久久久久| A级毛片无码久久精品免费| 国产AⅤ精品一区二区三区久久| 久久丫忘忧草产品| 久久精品国产亚洲av瑜伽| 狠狠干狠狠久久| 中文字幕乱码人妻无码久久| 午夜精品久久久久久久无码| 99久久国产综合精品网成人影院 | 精品午夜久久福利大片| 久久综合九色综合网站| 狠狠色丁香久久婷婷综合_中| 久久精品国产亚洲AV不卡| 国产一区二区精品久久岳| 欧美亚洲国产精品久久蜜芽| 久久精品国产亚洲av麻豆色欲| 久久久久久国产精品美女| 天堂无码久久综合东京热| 狠狠色伊人久久精品综合网| 国产一级持黄大片99久久| 久久久久久九九99精品| 久久久久国产精品熟女影院 | 亚洲精品99久久久久中文字幕| 国内精品久久久久久久影视麻豆| 国产精品久久久久影院色| 久久精品国产一区二区三区日韩| 久久se精品一区精品二区| 国产午夜精品理论片久久| 色综合久久88色综合天天 |