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

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

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

  • <tfoot id='neKm8'></tfoot>

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

      1. C++ 重載函數(shù)作為模板參數(shù)

        C++ overloaded function as template argument(C++ 重載函數(shù)作為模板參數(shù))
      2. <i id='WayMj'><tr id='WayMj'><dt id='WayMj'><q id='WayMj'><span id='WayMj'><b id='WayMj'><form id='WayMj'><ins id='WayMj'></ins><ul id='WayMj'></ul><sub id='WayMj'></sub></form><legend id='WayMj'></legend><bdo id='WayMj'><pre id='WayMj'><center id='WayMj'></center></pre></bdo></b><th id='WayMj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WayMj'><tfoot id='WayMj'></tfoot><dl id='WayMj'><fieldset id='WayMj'></fieldset></dl></div>

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

            <tbody id='WayMj'></tbody>

            <tfoot id='WayMj'></tfoot>
            <legend id='WayMj'><style id='WayMj'><dir id='WayMj'><q id='WayMj'></q></dir></style></legend>

              • <bdo id='WayMj'></bdo><ul id='WayMj'></ul>
                  本文介紹了C++ 重載函數(shù)作為模板參數(shù)的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我的代碼的簡化版本在這里

                  the simplified version of my code is here

                  int foo(int x)
                  {
                    return x;
                  }
                  
                  int foo(int x, int y)
                  {
                    return x+y;
                  }
                  
                  template<typename unary_func>
                  int bar(int k, unary_func f)
                  {
                    return f(k);
                  }
                  
                  int main()
                  {
                    bar(3, foo);
                    return 0;
                  }
                  

                  有沒有辦法告訴編譯器我想傳遞的參數(shù)是第一個‘foo’?

                  Is there a way to tell the compiler what I want to pass as argument is the first `foo'?

                  推薦答案

                  你可以給出一個明確的模板參數(shù):

                  You can give an explicit template argument:

                  bar<int(int)>(3, foo);
                  

                  或?qū)⒛@鈨煽傻暮瘮?shù)名稱強(qiáng)制轉(zhuǎn)換為可以從中推導(dǎo)出模板參數(shù)的類型:

                  or cast the ambiguous function name to a type from which the template argument can be deduced:

                  bar(3, static_cast<int(*)(int)>(foo));
                  

                  或?qū)⑵浒b在另一個函數(shù)(或函數(shù)對象)中以消除歧義

                  or wrap it in another function (or function object) to remove the ambiguity

                  bar(3, [](int x){return foo(x);});
                  

                  這篇關(guān)于C++ 重載函數(shù)作為模板參數(shù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 不能)

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

                        <bdo id='nHr0C'></bdo><ul id='nHr0C'></ul>
                        <i id='nHr0C'><tr id='nHr0C'><dt id='nHr0C'><q id='nHr0C'><span id='nHr0C'><b id='nHr0C'><form id='nHr0C'><ins id='nHr0C'></ins><ul id='nHr0C'></ul><sub id='nHr0C'></sub></form><legend id='nHr0C'></legend><bdo id='nHr0C'><pre id='nHr0C'><center id='nHr0C'></center></pre></bdo></b><th id='nHr0C'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='nHr0C'><tfoot id='nHr0C'></tfoot><dl id='nHr0C'><fieldset id='nHr0C'></fieldset></dl></div>
                              <tbody id='nHr0C'></tbody>
                          1. <tfoot id='nHr0C'></tfoot>
                          2. <legend id='nHr0C'><style id='nHr0C'><dir id='nHr0C'><q id='nHr0C'></q></dir></style></legend>
                            主站蜘蛛池模板: 国产欧美精品一区二区三区 | 中文字字幕在线中文乱码范文 | 久久精品视频在线播放 | 伊人一区 | 日韩免费视频一区二区 | 欧美亚洲视频在线观看 | 亚洲一区二区三区在线视频 | 91久久婷婷 | 在线观看亚洲精品 | 国产精品亚洲综合 | 午夜精品福利视频 | 国产97色 | 欧美精品久久久 | 久久久久亚洲精品国产 | 黄视频网址 | 9999国产精品欧美久久久久久 | 岛国午夜 | 日韩久草 | 欧美成人精品欧美一级 | 欧美一区二区久久 | 国产高清视频 | 一区二区三区四区视频 | 色在线免费视频 | 免费精品在线视频 | 久久久91精品国产一区二区三区 | 久久久国产一区二区三区 | 亚洲成人精选 | 欧美视频三级 | 午夜精品久久久久久久久久久久久 | 国产激情 | 一区二区在线观看av | 久久久久久高潮国产精品视 | 欧美日韩精品一区二区三区视频 | 九九热在线免费视频 | 亚洲区一区二 | 视频在线一区二区 | 日韩日韩日韩日韩日韩日韩日韩 | 亚洲成人av一区二区 | 久久精品国产免费一区二区三区 | 九九九久久国产免费 | 成人在线小视频 |