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

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            狠狠色丁香婷婷综合久久来| 久久中文字幕视频、最近更新| 国产精品综合久久第一页| 精品久久久久久国产牛牛app| 久久久国产视频| 精品久久久久香蕉网| 午夜精品久久影院蜜桃| 久久99精品久久久久子伦| 91精品国产高清久久久久久91| 久久久无码一区二区三区| 亚洲AV伊人久久青青草原| 亚洲AV日韩精品久久久久久| 久久久久久噜噜精品免费直播| 热re99久久精品国99热| 97精品伊人久久大香线蕉| 日本精品久久久久中文字幕| 亚洲精品无码久久千人斩| 国产成人久久777777| 色妞色综合久久夜夜| 伊人久久无码精品中文字幕| 欧美激情精品久久久久久久| 久久青青草原精品国产| 久久国内免费视频| 狠狠精品久久久无码中文字幕| 久久亚洲精品无码AV红樱桃| 热久久国产欧美一区二区精品| 99久久精品免费国产大片| 精品人妻久久久久久888| 久久99久久99精品免视看动漫| 久久香综合精品久久伊人| 久久久久婷婷| 久久激情五月丁香伊人| 国产精品久久久久乳精品爆| 久久777国产线看观看精品| 久久久国产精品亚洲一区| 久久精品国产亚洲αv忘忧草 | 久久夜色精品国产噜噜亚洲a| 国产叼嘿久久精品久久| 久久黄色视频| 国产精品乱码久久久久久软件| 亚洲伊人久久综合影院|