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

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            99久久精品国产一区二区| 人妻精品久久久久中文字幕69| 69国产成人综合久久精品| 久久成人国产精品免费软件| 中文精品99久久国产| 精品国产乱码久久久久久人妻| 亚洲午夜久久久久久久久电影网 | 久久夜色精品国产网站| 久久久久99精品成人片直播| 久久高潮一级毛片免费| 久久精品国产99久久久古代| 久久99精品国产99久久| 久久乐国产综合亚洲精品| 久久777国产线看观看精品| 看全色黄大色大片免费久久久 | 日批日出水久久亚洲精品tv| 亚洲AV日韩精品久久久久久久| 国产激情久久久久影院老熟女| 中文字幕无码av激情不卡久久| 狠狠色婷婷综合天天久久丁香| 久久福利资源国产精品999| 色综合色天天久久婷婷基地| 久久午夜无码鲁丝片| 亚洲欧美一区二区三区久久| 精品多毛少妇人妻AV免费久久| 色综合合久久天天给综看| 国产69精品久久久久9999| 无码人妻少妇久久中文字幕蜜桃| 欧美久久久久久午夜精品| 狠狠色丁香久久综合五月| 99久久人妻无码精品系列蜜桃| 老色鬼久久亚洲AV综合| 亚洲日本久久久午夜精品| 一本大道久久香蕉成人网| 精品99久久aaa一级毛片| 国内精品久久久久久久涩爱| MM131亚洲国产美女久久| 国产一区二区三区久久精品| 狠狠色婷婷综合天天久久丁香| 国产成人综合久久综合| 久久精品国产亚洲综合色|