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

    • <bdo id='RLyW0'></bdo><ul id='RLyW0'></ul>
    1. <legend id='RLyW0'><style id='RLyW0'><dir id='RLyW0'><q id='RLyW0'></q></dir></style></legend>

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

        <tfoot id='RLyW0'></tfoot>

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

        為什么兩個函數的地址相同?

        Why do two functions have the same address?(為什么兩個函數的地址相同?)

        <small id='3tZFS'></small><noframes id='3tZFS'>

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

              <bdo id='3tZFS'></bdo><ul id='3tZFS'></ul>
                <tbody id='3tZFS'></tbody>

                  <i id='3tZFS'><tr id='3tZFS'><dt id='3tZFS'><q id='3tZFS'><span id='3tZFS'><b id='3tZFS'><form id='3tZFS'><ins id='3tZFS'></ins><ul id='3tZFS'></ul><sub id='3tZFS'></sub></form><legend id='3tZFS'></legend><bdo id='3tZFS'><pre id='3tZFS'><center id='3tZFS'></center></pre></bdo></b><th id='3tZFS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3tZFS'><tfoot id='3tZFS'></tfoot><dl id='3tZFS'><fieldset id='3tZFS'></fieldset></dl></div>
                • 本文介紹了為什么兩個函數的地址相同?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  考慮這個函數模板:

                  template<typename T>
                  unsigned long f(void *) { return 0;}
                  

                  現在,我將 ff 的地址打印為:

                  Now, I print the addresses of f<A> and f<B> as:

                  std::cout << (void*)f<A> << std::endl;
                  std::cout << (void*)f<B> << std::endl;
                  

                  如果在 MSVS10 中編譯,為什么它們打印相同的地址?它們不是兩個不同的功能,因此應該打印不同的地址嗎?

                  Why do they print the same address if compiled in MSVS10? Are they not two different functions and therefore should print different addresses?

                  更新:

                  我意識到在 ideone 上,它會打印不同的地址.MSVS10 優化了代碼,因為該函數不以任何方式依賴 T,因此它產生相同的函數.@Mark 對此的回答和評論很有價值.:-)

                  I realized that on ideone, it prints the different address. MSVS10 optimizes the code, as the function doesn't depend on T in any way, so it produces same function. @Mark's answer and comments on this are valuable. :-)

                  推薦答案

                  由于函數不依賴模板參數,編譯器可以將所有實例化為一個函數.

                  Since the function doesn't depend on the template parameter, the compiler can condense all instantiations into a single function.

                  我不知道你為什么得到 1 作為地址.

                  I don't know why you get 1 for the address.

                  我用我的真實代碼進行了試驗,并得出結論,@Mark 上面所說的在這里非常重要:

                  I experimented with my real code, and concluded that what @Mark said above is very important here :

                  由于函數不依賴于模板參數,編譯器可以將所有實例化為一個函數.

                  我還得出一個結論,如果函數體依賴于T*,而不是T,它仍然為我的不同類型參數生成相同的函數真正的代碼(雖然不是在 ideone 上).然而,如果它依賴于 T,那么它會產生不同的函數,因為 sizeof(T) 對于不同的類型參數是不同的(對我來說很幸運).

                  I also came to a conclusion that if the function-body depends on T*, not on T, it still produces the same function for different type arguments in my real code (not on ideone, though). However, if it depends on T, then it produces different functions, because sizeof(T) differs (fortunately for me) for different type arguments.

                  所以我在函數模板中添加了一個 T 類型的虛擬 automatic 變量,這樣函數就可以依賴于 T 的大小從而強制它產生不同的功能.

                  So I added a dummy automatic variable of type T in the function template, so that the function could depend on the size of T so as to force it to produce different functions.

                  這篇關于為什么兩個函數的地址相同?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  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 不能)
                  Strong typedefs(強類型定義)

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

                          <tfoot id='tgDcP'></tfoot>
                        2. <legend id='tgDcP'><style id='tgDcP'><dir id='tgDcP'><q id='tgDcP'></q></dir></style></legend>

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

                            主站蜘蛛池模板: 午夜免费毛片 | 另类在线视频 | 日韩中文字幕在线 | 精品免费在线 | 中文字幕国产 | 精品国产久 | 丁香久久 | 麻豆chinese新婚xxx | 免费黄色小说网站 | 亚洲免费专区 | 欧美黄网站 | 毛片网站在线播放 | av在线免费网站 | 中文字幕在线观看一区二区三区 | 高hnp失禁3p小公主 | 三年中文在线观看免费大全中国 | 成人黄色在线视频 | 91三级视频| 黑人操亚洲女人 | 亚洲精品1区 | 青草导航 | 黄色成人av | 夜夜嗨av一区二区三区 | 欧美在线小视频 | 色中色综合 | 国产一级片视频 | 欧美又粗又长 | 国产一区视频在线播放 | 日韩国产精品视频 | 婷婷综合五月天 | 日本一级淫片色费放 | 日韩av手机在线观看 | 日日夜夜狠狠干 | 亚洲亚洲人成综合网络 | 日韩一级免费视频 | 亚洲性生活视频 | 色综合天天综合网天天狠天天 | 久久久久久国产 | 高清视频一区二区 | 欧美精品亚洲 | 少妇激情视频 |