pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<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="h9rl5l7" 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>

        默認模板參數偏特化

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

          <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="57btrll" 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>

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

                  問題描述

                  限時送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;
                  }
                  

                  不應該屬于模板類Base的泛化形式嗎?

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

                  推薦答案

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

                  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而不是基礎模板提供的默認值:

                  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.

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

                  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.

                  然后(作為一個基本上獨立的步驟)它對適合這些參數類型的所有模板執行重載決議的模擬.與通常的重載解析一樣,顯式指定的類型優先于隱式指定的類型,因此您的專業化(顯式指定 int)優先于基本模板(指定 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).

                  這篇關于默認模板參數偏特化的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 不能)

                    • <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="5bntpjj" 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'>

                            主站蜘蛛池模板: 黄石妇科医院_黄石东方女子医院_黄石东方妇产医院怎么样 | 食品质构分析仪-氧化诱导分析仪-瞬态法导热系数仪|热冰百科 | 工控机-工业平板电脑-研华工控机-研越无风扇嵌入式box工控机 | 山东信蓝建设有限公司官网| 专业生物有机肥造粒机,粉状有机肥生产线,槽式翻堆机厂家-郑州华之强重工科技有限公司 | 真空吸污车_高压清洗车厂家-程力专用汽车股份有限公司官网 | ptc_浴霸_大巴_干衣机_呼吸机_毛巾架_电动车加热器-上海帕克 | 智慧食堂_食堂管理系统_食堂订餐_食堂消费系统—客易捷 | 空压机商城|空气压缩机|空压机配件-压缩机网旗下商城 | SF6环境监测系统-接地环流在线监测装置-瑟恩实业 | 密度电子天平-内校-外校电子天平-沈阳龙腾电子有限公司 | LED灯杆屏_LED广告机_户外LED广告机_智慧灯杆_智慧路灯-太龙智显科技(深圳)有限公司 | 胶水,胶粘剂,AB胶,环氧胶,UV胶水,高温胶,快干胶,密封胶,结构胶,电子胶,厌氧胶,高温胶水,电子胶水-东莞聚力-聚厉胶粘 | 自清洗过滤器,浅层砂过滤器,叠片过滤器厂家-新乡市宇清净化 | 碳钢法兰厂家,非标法兰,定制异型,法兰生产厂家-河北九瑞管道 | 冷凝水循环试验箱-冷凝水试验箱-可编程高低温试验箱厂家-上海巨为(www.juweigroup.com) | TPM咨询,精益生产管理,5S,6S现场管理培训_华谋咨询公司 | 活性炭-果壳木质煤质柱状粉状蜂窝活性炭厂家价格多少钱 | 合肥花魁情感婚姻咨询中心_挽回爱情_修复婚姻_恋爱指南 | 真空干燥烘箱_鼓风干燥箱 _高低温恒温恒湿试验箱_光照二氧化碳恒温培养箱-上海航佩仪器 | LED灯杆屏_LED广告机_户外LED广告机_智慧灯杆_智慧路灯-太龙智显科技(深圳)有限公司 | 深圳天际源广告-形象堆头,企业文化墙,喷绘,门头招牌设计制作专家 | 高尔夫球杆_高尔夫果岭_高尔夫用品-深圳市新高品体育用品有限公司 | 卸料器-卸灰阀-卸料阀-瑞安市天蓝环保设备有限公司 | 根系分析仪,大米外观品质检测仪,考种仪,藻类鉴定计数仪,叶面积仪,菌落计数仪,抑菌圈测量仪,抗生素效价测定仪,植物表型仪,冠层分析仪-杭州万深检测仪器网 | 【365公司转让网】公司求购|转让|资质买卖_股权转让交易平台 | 嘉兴泰东园林景观工程有限公司_花箱护栏 | 山西3A认证|太原AAA信用认证|投标AAA信用证书-山西AAA企业信用评级网 | 煤矿支护网片_矿用勾花菱形网_缝管式_管缝式锚杆-邯郸市永年区志涛工矿配件有限公司 | COD分析仪|氨氮分析仪|总磷分析仪|总氮分析仪-圣湖Greatlake | 旋片真空泵_真空泵_水环真空泵_真空机组-深圳恒才机电设备有限公司 | 蒜肠网-动漫,二次元,COSPLAY,漫展以及收藏型模型,手办,玩具的新媒体.(原变形金刚变迷TF圈) | 智能案卷柜_卷宗柜_钥匙柜_文件流转柜_装备柜_浙江福源智能科技有限公司 | 「银杏树」银杏树行情价格_银杏树种植_山东程锦园林 | 干式磁选机_湿式磁选机_粉体除铁器-潍坊国铭矿山设备有限公司 | 智能终端_RTU_dcm_北斗星空自动化科技 | 开云(中国)Kaiyun·官方网站 - 登录入口| 螺杆真空泵_耐腐蚀螺杆真空泵_水环真空泵_真空机组_烟台真空泵-烟台斯凯威真空 | 北京网站建设首页,做网站选【优站网】,专注北京网站建设,北京网站推广,天津网站建设,天津网站推广,小程序,手机APP的开发。 | 垃圾处理设备_餐厨垃圾处理设备_厨余垃圾处理设备_果蔬垃圾处理设备-深圳市三盛环保科技有限公司 | 糖衣机,除尘式糖衣机,全自动糖衣机,泰州市长江制药机械有限公司 体感VRAR全息沉浸式3D投影多媒体展厅展会游戏互动-万展互动 |