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

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            色综合久久中文字幕无码| 91精品国产91久久久久久| 久久综合久久伊人| 要久久爱在线免费观看| 久久国产免费直播| 国产精品福利一区二区久久| 国产精品伊人久久伊人电影| 狠狠色丁香久久婷婷综合图片| 亚洲中文字幕无码久久综合网| 国产精品无码久久久久久| 国产精品美女久久久免费| 国产亚洲精久久久久久无码77777| 久久精品国产99久久久| 精品无码久久久久久久动漫| 亚洲欧美伊人久久综合一区二区| 久久综合九色综合97_久久久| 伊人久久大香线蕉成人| 久久成人精品视频| 亚洲人成伊人成综合网久久久| 国产叼嘿久久精品久久| 国产成人精品免费久久久久| 中文成人久久久久影院免费观看| 蜜桃麻豆www久久| av色综合久久天堂av色综合在| 久久精品成人| 国产精品99久久不卡| AAA级久久久精品无码片| 久久精品国产亚洲AV香蕉| 少妇久久久久久被弄到高潮 | 久久久噜噜噜久久| 久久免费线看线看| 久久久久亚洲AV成人片| 人人狠狠综合久久亚洲| 精品水蜜桃久久久久久久| 国产成人精品久久综合 | 精品久久久无码中文字幕天天| 久久综合久久综合亚洲| 亚洲国产精品综合久久一线| 久久久精品日本一区二区三区 | 伊人精品久久久久7777| 人妻无码久久精品|