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

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            无码任你躁久久久久久| 亚洲精品无码久久久久去q | 曰曰摸天天摸人人看久久久| 国内精品久久久久国产盗摄| 99久久精品免费国产大片| 国产真实乱对白精彩久久| 久久97久久97精品免视看| 色偷偷88欧美精品久久久| 精品熟女少妇AV免费久久| 久久国产精品一区| 亚洲国产精品成人久久蜜臀| 国内精品久久久久久久亚洲| 亚州日韩精品专区久久久| 伊人久久精品无码av一区| 99久久精品费精品国产一区二区| 久久国产三级无码一区二区| 无码精品久久一区二区三区 | 国产成人精品久久| 久久99亚洲网美利坚合众国| 久久精品人人槡人妻人人玩AV | 久久精品国产免费一区| 亚洲精品无码久久毛片| 国产精品伊人久久伊人电影| 99国产欧美久久久精品蜜芽| 亚洲中文字幕久久精品无码喷水| 色综合久久中文字幕综合网| 国产精品热久久毛片| 国内精品伊人久久久久| 久久亚洲欧美国产精品| 伊人久久大香线蕉AV色婷婷色| 伊人久久大香线蕉AV一区二区 | 日产精品久久久久久久| 亚洲欧洲日产国码无码久久99| 久久精品中文无码资源站| 狠狠色婷婷久久一区二区| 亚洲第一极品精品无码久久| 亚洲AV无码1区2区久久| 亚洲国产精品久久久久久| 狠狠精品久久久无码中文字幕| 久久久久久亚洲精品不卡| 亚洲精品乱码久久久久久蜜桃 |