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


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            導(dǎo)航

            統(tǒng)計

            常用鏈接

            留言簿

            隨筆分類(23)

            隨筆檔案(26)

            文章分類(1)

            文章檔案(1)

            csdn

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久久青草大香综合精品 | 丁香五月网久久综合| 亚洲精品无码久久千人斩| 国产精品无码久久久久久| 久久久久久极精品久久久| 久久综合色老色| 久久99国产精品一区二区| 国产精品乱码久久久久久软件| 97精品久久天干天天天按摩 | 一本一道久久综合狠狠老| 麻豆精品久久精品色综合| 国产激情久久久久久熟女老人| 久久精品人人做人人爽电影| 一本色道久久综合| 久久久99精品成人片中文字幕 | 一本大道久久东京热无码AV| 久久国产精品-久久精品| 久久精品成人欧美大片| 久久国产成人精品国产成人亚洲| 久久青青草原亚洲av无码app| 日韩一区二区三区视频久久| 婷婷久久综合九色综合98| 国内精品人妻无码久久久影院 | 久久午夜羞羞影院免费观看| 久久精品中文字幕大胸| 亚洲国产成人精品女人久久久 | 成人国内精品久久久久影院VR| 久久久久久午夜成人影院| 亚洲精品乱码久久久久久中文字幕| 精品久久人人做人人爽综合| 国产A级毛片久久久精品毛片| 97精品伊人久久大香线蕉app| 久久久久亚洲av无码专区喷水 | 国产午夜久久影院| 国产成人综合久久综合| 精品久久久久久久久午夜福利| 欧美精品久久久久久久自慰| 久久国产精品成人影院| 青青青国产成人久久111网站| 办公室久久精品| 久久无码专区国产精品发布|