久久久久久久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++如何鏈接模板實例的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  如果我在包含兩個不同翻譯單元的頭文件中定義一個函數(可能是一個類成員函數但未內聯),我會收到鏈接錯誤,因為該函數是多重定義的.模板并非如此,因為在編譯器解析模板化類型的對象聲明之前,它們不是可編譯的類型.這讓我意識到我不知道編譯的模板代碼在哪里以及它是如何鏈接的,因為 C++ 不只是創建代碼的多個副本來定義 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種實現方案:

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

                  • 貪婪實例化,編譯器在每個使用它的編譯單元中生成一個實例化,然后鏈接器丟棄除其中一個之外的所有實例化(這不僅僅是代碼大小優化,它是必需的,以便函數地址、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.

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

                  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 相比進行了一些優化).

                  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,更關注編譯模型,但仍然有實例化機制的描述).

                  (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).

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

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

                  相關文檔推薦

                  Why do two functions have the same address?(為什么兩個函數的地址相同?)
                  Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復制構造的?)
                  mixing templates with polymorphism(混合模板與多態性)
                  When should I use the keyword quot;typenamequot; when using templates(我什么時候應該使用關鍵字“typename?使用模板時)
                  Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標準庫)
                  gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數模板,而 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>
                          • 主站蜘蛛池模板: 久久99精品久久久久久琪琪 | 亚洲一区二区三区四区在线观看 | 欧美激情在线精品一区二区三区 | 五月婷婷中文 | 日韩精品一区二区三区中文在线 | 国产精品免费一区二区三区四区 | 亚洲黄色高清视频 | 97伦理电影 | 99精品欧美一区二区蜜桃免费 | av播播| 欧美福利视频一区 | 国产精品毛片无码 | 请别相信他免费喜剧电影在线观看 | 免费成人高清 | 日本精品视频 | 91国语清晰打电话对白 | 福利片在线观看 | 成人av一区二区三区 | 一区二区国产精品 | 色橹橹欧美在线观看视频高清 | 国产美女自拍视频 | 久久久国产精品一区 | 婷婷久久一区 | 成人精品一区 | 亚洲三级视频 | 最新日韩欧美 | 成人在线不卡 | 欧美又大粗又爽又黄大片视频 | 中文字幕在线观看一区二区 | 国产精品视频中文字幕 | 成人在线免费观看视频 | 久热精品免费 | 国产成人精品一区二区三区视频 | 日日夜精品视频 | 成人亚洲精品久久久久软件 | 国产高清精品一区 | 日韩高清中文字幕 | 国产精品日日夜夜 | 欧美日韩久久久 | 日日摸日日碰夜夜爽亚洲精品蜜乳 | 国产精品区一区二 |