久久久久久久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>

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

        Default template parameter partial specialization(默認(rèn)模板參數(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>

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

                  問題描述

                  限時(shí)送ChatGPT賬號..

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

                  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?

                  推薦答案

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

                  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>
                  // ...
                  

                  ...是一個(gè)錯(cuò)誤.

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

                  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í)例化時(shí)沒有指定類型),兩種類型都基于基本模板中指定的默認(rèn)模板參數(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.

                  然后(作為一個(gè)基本上獨(dú)立的步驟)它對適合這些參數(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)于默認(rè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?(為什么兩個(gè)函數(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(我什么時(shí)候應(yīng)該使用關(guān)鍵字“typename?使用模板時(shí))
                  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 不能)

                    • <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乱码一区二区三区 | 日韩精品一区二区三区在线播放 | 99免费在线视频 | 狠狠av| 国产高清视频一区 | 成人动漫视频网站 | 国产999精品久久久久久绿帽 | 国产探花 | 日韩视频精品在线 | 99精品欧美一区二区三区 | 亚洲欧美一区二区三区视频 | 国产乱码高清区二区三区在线 | 成年人在线 | caoporon| 成人免费观看男女羞羞视频 | 中文字幕一区二区三区精彩视频 | av日韩精品| 天天操天天拍 | 日韩亚洲一区二区 | 亚洲精品乱码久久久久久蜜桃91 | 人人擦人人干 | 欧美日韩在线观看视频 | 国产传媒在线播放 | 久久久久久国产精品久久 | 日日av | 亚洲高清在线观看 | 成年人黄色免费视频 | 91九色在线观看 | 国产精品99999999 | 羞羞视频网 | 欧美一区二区三区国产 | 欧美日韩国产一区二区三区 | 午夜免费视频 | 国产中文字幕在线 | 亚洲精品一区二区网址 | 亚洲精品永久免费 | 亚洲国产精品99久久久久久久久 |