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

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

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

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

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

        默認模板參數(shù)偏特化

        Default template parameter partial specialization(默認模板參數(shù)偏特化)

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

            1. <small id='4AJ9F'></small><noframes id='4AJ9F'>

                  <tbody id='4AJ9F'></tbody>

                  本文介紹了默認模板參數(shù)偏特化的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  請向我解釋為什么下面的代碼能夠完美運行.我很困惑.

                  Please explain to me why the following piece of code complies and works perfectly. I am very confused.

                  #include<iostream>
                  template<class A = int, class B=double>
                  class Base
                  {};
                  
                  template<class B>
                  class Base <int, B>
                  {
                  public:
                    Base()
                    {
                       std::cout<<"it works!!!!!
                  ";
                    }
                  };
                  
                  int main()
                  {
                    Base<> base; // it prints "it works!!!!!"
                    return 0;
                  }
                  

                  不應(yīng)該屬于模板類Base的泛化形式嗎?

                  Shouldn't it fall into the generalized form of the template class Base?

                  推薦答案

                  默認參數(shù)適用于特化——事實上,特化必須接受(可以這么說)基模板的默認參數(shù).嘗試在專業(yè)化中指定默認值:

                  The default argument applies to the specialization -- and, in fact, a specialization must accept (so to speak) the base template's default argument(s). Attempting to specify a default in the specialization:

                  template<class A = int, class B=double>
                  class Base
                  {};
                  
                  template<class B=char>
                  // ...
                  

                  ...是一個錯誤.

                  同樣,如果我們改變特化,使它的特化是針對一個類型other而不是基礎(chǔ)模板提供的默認值:

                  Likewise, if we change the specialization so that its specialization is for a type other than the default provided by the base template:

                  template<class A = int, class B=double>
                  class Base
                  {};
                  
                  template<class B>
                  class Base <char, B>
                  

                  ...然后將選擇基本模板.

                  ...then the base template will be chosen.

                  所以,發(fā)生的事情是:首先選擇模板參數(shù)的類型.在這種情況下(在實例化時沒有指定類型),兩種類型都基于基本模板中指定的默認模板參數(shù).

                  So, what's happening is this: first the types for the template arguments are chosen. In this case (no type specified at instantiation), both types are based on the default template arguments specified in the base template.

                  然后(作為一個基本上獨立的步驟)它對適合這些參數(shù)類型的所有模板執(zhí)行重載決議的模擬.與通常的重載解析一樣,顯式指定的類型優(yōu)先于隱式指定的類型,因此您的專業(yè)化(顯式指定 int)優(yōu)先于基本模板(指定 int代碼> 隱式).

                  Then (as a basically separate step) it carries out an analog of overload resolution on all templates that fit those argument types. As usual for overload resolution, a type that's specified explicitly is preferred over one that's specified implicitly, so your specialization (which specified int explicitly) is preferred over the base template (which specified int implicitly).

                  這篇關(guān)于默認模板參數(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/標準庫)
                  gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數(shù)模板,而 clang 不能)

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

                          <tfoot id='o9I0f'></tfoot>
                            <bdo id='o9I0f'></bdo><ul id='o9I0f'></ul>

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

                            主站蜘蛛池模板: 91看片在线观看 | 91精品免费视频 | 在线免费观看黄色片 | 男人天堂手机在线 | 亚洲一级精品 | 8090理论片午夜理伦片 | 久草青青草 | 日韩成人精品 | 亚洲午夜18毛片在线看 | 成人a毛片| 亚洲欧美在线一区 | 国产精品无遮挡 | 日韩视频免费 | 欧美一级黄色录像 | 久久一区二区三区四区 | 五月天婷婷激情网 | 日韩激情网站 | 国产精品2| 午夜网站在线观看 | 天天色视频| 日韩在线免费播放 | 97精品国产97久久久久久免费 | 日韩视频网 | 一级黄色网 | 国产精品123区 | 国产精品免费一区 | 日本免费一级片 | 欧美成人免费 | 91在线看片| 综合网久久 | 精品国产久 | 三级黄色片网站 | 久久久www成人免费精品 | 亚洲一区二区欧美 | 亚洲天堂久久久 | av手机天堂网 | 日本国产精品 | 色婷婷精品国产一区二区三区 | 亚洲精品乱码久久久久久动漫 | www欧美| 亚洲+小说+欧美+激情+另类 |