• <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 中 臨時對象作為參數傳遞給 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)  編輯 收藏 引用

            導航

            統計

            常用鏈接

            留言簿

            隨筆分類(23)

            隨筆檔案(26)

            文章分類(1)

            文章檔案(1)

            csdn

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            97久久精品午夜一区二区| 国产一区二区精品久久岳| 久久久久国产精品人妻| 久久久久久久久久久| 99久久777色| 综合久久精品色| 亚洲精品午夜国产VA久久成人| 国产精品久久国产精品99盘| 久久97久久97精品免视看秋霞| 久久天天躁狠狠躁夜夜avapp| 热re99久久精品国99热| 久久久久国产视频电影| 精品久久久久中文字幕日本 | 狠狠综合久久综合中文88| 色综合久久夜色精品国产| 97r久久精品国产99国产精| 色偷偷88欧美精品久久久| 91精品国产综合久久婷婷| 2020国产成人久久精品| 久久久久18| 曰曰摸天天摸人人看久久久| 中文字幕乱码久久午夜| 国产99久久久久久免费看| 蜜臀av性久久久久蜜臀aⅴ | 青青国产成人久久91网| 色综合久久天天综线观看| 国内精品久久久久久99蜜桃| 无码人妻少妇久久中文字幕 | 国产精品99久久99久久久| 天天做夜夜做久久做狠狠| 中文精品久久久久国产网址| 久久久久亚洲av无码专区| 99精品久久精品一区二区| 99精品国产99久久久久久97| 久久这里都是精品| 2021国内精品久久久久久影院| 四虎影视久久久免费| 精品国产日韩久久亚洲| 久久人做人爽一区二区三区 | 精品国产91久久久久久久a | 婷婷久久久亚洲欧洲日产国码AV|