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

            <2025年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            導航

            統計

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            色婷婷久久综合中文久久一本| 精品久久久久久久国产潘金莲 | 老司机午夜网站国内精品久久久久久久久| 青青青国产精品国产精品久久久久| 国产精品热久久毛片| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 日本精品久久久久影院日本| 国产精品亚洲综合久久| 成人久久精品一区二区三区| 无码8090精品久久一区| a高清免费毛片久久| 久久综合九色综合网站| 欧美精品一区二区精品久久| 精品久久久久久无码不卡| 久久99精品国产一区二区三区| 久久久久人妻一区精品| 久久精品国产亚洲av水果派| 久久久久久亚洲精品不卡| 欧美久久综合性欧美| 婷婷久久久亚洲欧洲日产国码AV| 国产三级精品久久| 久久AV高清无码| 精品国产乱码久久久久久呢| 久久国产成人| 99久久免费只有精品国产| 国产亚洲精品美女久久久| 少妇高潮惨叫久久久久久 | 久久AAAA片一区二区| 99久久成人国产精品免费 | 久久精品中文字幕无码绿巨人 | 亚洲成色999久久网站| 亚洲国产精品无码久久| 国产精品美女久久福利网站| 久久久久99精品成人片三人毛片 | 亚洲人成网亚洲欧洲无码久久 | 国产成年无码久久久久毛片| 中文精品久久久久人妻不卡| 思思久久99热只有频精品66| 伊人久久大香线蕉综合网站| 亚洲欧美日韩精品久久亚洲区| 亚洲国产成人精品无码久久久久久综合|