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

            C++ library系列 -- STL實現中的ODR “one-definition-rule” for types

            Linking issue
            - While different modules (.obj) using istreambuf_iterator/ostreambuf_iterator, compiled with different options on HID/no-HID and SCL/no-SCL, these modules could not be linked successfully;

            The error comes directly from the CLR when a type has multiple definitions that are not consistent based upon the ODR, one-definition-rule for types. And, the linker itself isn't involved.

            For example, with one module compile with /D_SECURE_SCL=0, while another is compiled with _SECURE_SCL=1;

            At first, it's found that with _SECURE_SCL, the only thing that could be different as following,

            #if _SECURE_SCL
                typedef _Range_checked_iterator_tag _Checked_iterator_category;
            #endif

            But, actually, it's not the typedef that changed the layout the these iterators (istreambuf_iterator/ostreambuf_iterator), and further they don't really use the extra pointer that _SECURE_SCL adds.

            Finally, it's found the root cause is that, these iterators, istreambuf_iterator/ostreambuf_iterator  had been moved from <xutility> to <streambuf>, and their ultimate base class had been changed from _Iterator_base_secure to _Iterator_base. And, the layout of _Iterator_base would be different between HID and no-HID, and between SCL and no-SCL. It is the cause where the issue comes from.

            What we can learn from such issue,
            These iterators really shouldn't derive from either _Iterator_base_secure or _Iterator_base, because these classes contain data members (pointers) which are entirely unused. It would result in unnecessary bloat and extra work being performed in ctor/dtor etc.

            Introduce a new class, _Iterator_base_universal, which is defined identically regardless of HID/no-HID and SCL/no-SCL. It would contains the three internal typedefs that all standard iterators need to have, and nothing else. And _Iterator_base (in all of its variants) and _Iterator_base_secure now should derive from _Iterator_base_universal to get these typedefs.

            Now, when an iterator wants these typedefs, but not the data members of _Iterator_base and _Iterator_base_secure, it could derive from _Iterator_base_universal. And istreambuf_iterator and ostreambuf_iterator are now as small as possible, and keep identical representations or layout across HID/no-HID, SCL/no-SCL.

            posted on 2010-12-19 11:09 flagman 閱讀(1900) 評論(0)  編輯 收藏 引用 所屬分類: C++

            <2010年12月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            導航

            統計

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            欧美粉嫩小泬久久久久久久| 久久天堂AV综合合色蜜桃网| 亚洲欧美国产日韩综合久久| 国产福利电影一区二区三区,免费久久久久久久精 | 国产精品美女久久久久av爽| 久久精品无码一区二区app| 久久99这里只有精品国产| 久久精品国产亚洲av日韩| 国产91久久精品一区二区| 热综合一本伊人久久精品| 久久久久人妻一区精品色| 日日狠狠久久偷偷色综合免费| 久久久久久久久久久精品尤物| 久久精品国产亚洲沈樵| 欧美精品丝袜久久久中文字幕 | 久久性生大片免费观看性| 久久夜色精品国产网站| 欧美久久综合九色综合| 国产情侣久久久久aⅴ免费| 国产精品gz久久久| 国产精品久久午夜夜伦鲁鲁| 久久影院亚洲一区| 国产精品九九久久免费视频| 亚洲AV无码久久精品成人| 色婷婷噜噜久久国产精品12p| 久久精品人人做人人妻人人玩 | 久久亚洲高清观看| 亚洲人成伊人成综合网久久久 | 久久精品国产亚洲AV不卡| 国产精品一区二区久久精品无码 | 久久国产精品偷99| 久久久国产精品网站| 男女久久久国产一区二区三区| 人人狠狠综合久久亚洲高清| 久久精品国产亚洲麻豆| 久久91精品久久91综合| A级毛片无码久久精品免费| 久久经典免费视频| 怡红院日本一道日本久久| 中文精品久久久久人妻不卡| 久久精品中文无码资源站|