久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <legend id='GAMB3'><style id='GAMB3'><dir id='GAMB3'><q id='GAMB3'></q></dir></style></legend>
      <tfoot id='GAMB3'></tfoot>

        <bdo id='GAMB3'></bdo><ul id='GAMB3'></ul>
      <i id='GAMB3'><tr id='GAMB3'><dt id='GAMB3'><q id='GAMB3'><span id='GAMB3'><b id='GAMB3'><form id='GAMB3'><ins id='GAMB3'></ins><ul id='GAMB3'></ul><sub id='GAMB3'></sub></form><legend id='GAMB3'></legend><bdo id='GAMB3'><pre id='GAMB3'><center id='GAMB3'></center></pre></bdo></b><th id='GAMB3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GAMB3'><tfoot id='GAMB3'></tfoot><dl id='GAMB3'><fieldset id='GAMB3'></fieldset></dl></div>

      <small id='GAMB3'></small><noframes id='GAMB3'>

      1. C++如何鏈接模板實例

        How does C++ link template instances(C++如何鏈接模板實例)

        • <i id='GUMuN'><tr id='GUMuN'><dt id='GUMuN'><q id='GUMuN'><span id='GUMuN'><b id='GUMuN'><form id='GUMuN'><ins id='GUMuN'></ins><ul id='GUMuN'></ul><sub id='GUMuN'></sub></form><legend id='GUMuN'></legend><bdo id='GUMuN'><pre id='GUMuN'><center id='GUMuN'></center></pre></bdo></b><th id='GUMuN'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GUMuN'><tfoot id='GUMuN'></tfoot><dl id='GUMuN'><fieldset id='GUMuN'></fieldset></dl></div>
          <tfoot id='GUMuN'></tfoot>

          • <legend id='GUMuN'><style id='GUMuN'><dir id='GUMuN'><q id='GUMuN'></q></dir></style></legend>
              <bdo id='GUMuN'></bdo><ul id='GUMuN'></ul>

              <small id='GUMuN'></small><noframes id='GUMuN'>

                    <tbody id='GUMuN'></tbody>
                  本文介紹了C++如何鏈接模板實例的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  如果我在包含兩個不同翻譯單元的頭文件中定義一個函數(shù)(可能是一個類成員函數(shù)但未內(nèi)聯(lián)),我會收到鏈接錯誤,因為該函數(shù)是多重定義的.模板并非如此,因為在編譯器解析模板化類型的對象聲明之前,它們不是可編譯的類型.這讓我意識到我不知道編譯的模板代碼在哪里以及它是如何鏈接的,因為 C++ 不只是創(chuàng)建代碼的多個副本來定義 SomeTemplateClass.任何信息,將不勝感激.謝謝!

                  If I define a function (maybe a class member function but not inlined) in a header file that is included by two different translation units I get a link error since that function is multiply defined. Not so with templates since they are not compilable types until the compiler resolves a declaration of an object of a templatized type. This made me realize I don't know where compiled template code resides and how it is linked since C++ does not just create multiple copies of code to define SomeTemplateClass. Any info would be appreciated. Thanks!

                  推薦答案

                  C++編譯器使用了3種實現(xiàn)方案:

                  There are 3 implementation schemes used by C++ compilers:

                  • 貪婪實例化,編譯器在每個使用它的編譯單元中生成一個實例化,然后鏈接器丟棄除其中一個之外的所有實例化(這不僅僅是代碼大小優(yōu)化,它是必需的,以便函數(shù)地址、static 變量等都是唯一的).這是最常見的模型.

                  • greedy instantiation, where the compiler generates an instantiation in each compilation unit that uses it, then the linker throws away all but one of them (this is not just a code-size optimization, it's required so that function addresses, static variables, and the like are unique). This is the most common model.

                  查詢實例化,其中編譯器有一個已經(jīng)完成的實例化數(shù)據(jù)庫.當(dāng)需要實例化時,會檢查并更新數(shù)據(jù)庫.我知道的唯一使用它的編譯器是 Sun 的,默認(rèn)情況下不再使用它.

                  queried instantiation, where the compiler has a database of instantiations already done. When an instantiation is needed, the DB is checked and updated. The only compiler I know which uses this is Sun's, and it isn't used by default anymore.

                  迭代實例化,其中實例化由鏈接器進行(直接或通過將它們分配給編譯單元,然后重新編譯).這是 CFront 使用的模型 - 即歷史上它是第一個使用的模型 - 以及使用 EDG 前端的編譯器(與 CFront 相比進行了一些優(yōu)化).

                  iterated instantiation, where the instantiations are made by the linker (either directly or by assigning them to a compilation unit, which will then be recompiled). This is the model used by CFront -- i.e. historically it was the first one used -- and also by compilers using the EDG front-end (with some optimisations compared to CFront).

                  (參見 C++ 模板,David Vandevoorde 和 Nicolai Josuttis 的完整指南.另一個在線參考是 http://www.bourguet.org/v2/cpplang/export.pdf,更關(guān)注編譯模型,但仍然有實例化機制的描述).

                  (See C++ Templates, The Complete Guide by David Vandevoorde and Nicolai Josuttis. Another online reference is http://www.bourguet.org/v2/cpplang/export.pdf, which is more concerned about the compilation model but still has descriptions of the instantiation mechanisms).

                  這篇關(guān)于C++如何鏈接模板實例的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Why do two functions have the same address?(為什么兩個函數(shù)的地址相同?)
                  Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復(fù)制構(gòu)造的?)
                  mixing templates with polymorphism(混合模板與多態(tài)性)
                  When should I use the keyword quot;typenamequot; when using templates(我什么時候應(yīng)該使用關(guān)鍵字“typename?使用模板時)
                  Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標(biāo)準(zhǔn)庫)
                  gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數(shù)模板,而 clang 不能)
                    <tbody id='ZEJTp'></tbody>
                    <legend id='ZEJTp'><style id='ZEJTp'><dir id='ZEJTp'><q id='ZEJTp'></q></dir></style></legend>
                    <i id='ZEJTp'><tr id='ZEJTp'><dt id='ZEJTp'><q id='ZEJTp'><span id='ZEJTp'><b id='ZEJTp'><form id='ZEJTp'><ins id='ZEJTp'></ins><ul id='ZEJTp'></ul><sub id='ZEJTp'></sub></form><legend id='ZEJTp'></legend><bdo id='ZEJTp'><pre id='ZEJTp'><center id='ZEJTp'></center></pre></bdo></b><th id='ZEJTp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ZEJTp'><tfoot id='ZEJTp'></tfoot><dl id='ZEJTp'><fieldset id='ZEJTp'></fieldset></dl></div>

                    <small id='ZEJTp'></small><noframes id='ZEJTp'>

                      • <bdo id='ZEJTp'></bdo><ul id='ZEJTp'></ul>

                          • <tfoot id='ZEJTp'></tfoot>
                          • 主站蜘蛛池模板: 久久久久一区 | 亚洲 中文 欧美 日韩 在线观看 | 久久精品这里 | 成人免费在线视频 | 成人免费av | 亚洲视频在线免费观看 | 91电影| 亚洲毛片| 在线观看国产wwwa级羞羞视频 | 国产一区二区三区 | 天天干精品 | 精品一区二区三区免费视频 | 日本午夜精品 | 在线观看亚洲精品视频 | 国产日韩欧美一区 | av久久| 精品国产乱码久久久久久88av | 一级毛片视频在线 | 日日操操 | 一区二区在线不卡 | 日日摸日日爽 | 亚洲性人人天天夜夜摸 | 成人激情视频免费观看 | 国产精品高清在线 | av天天爽 | 成人性视频免费网站 | 亚洲www啪成人一区二区麻豆 | 美女国产一区 | 成人国产午夜在线观看 | 免费观看一级毛片 | 中文字幕一区二区三区精彩视频 | 一级免费看 | 精品乱人伦一区二区三区 | 国产成人综合在线 | 久久精品中文字幕 | 日本久草 | 岛国精品| 亚洲精品电影 | 欧美高清性xxxxhd| 99精品视频一区二区三区 | 99久久久久国产精品免费 |