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

<tfoot id='hZS9D'></tfoot>

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

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

      1. std::enable_if 如何工作?

        How Does std::enable_if work?(std::enable_if 如何工作?)

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

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

              1. <legend id='XwY5K'><style id='XwY5K'><dir id='XwY5K'><q id='XwY5K'></q></dir></style></legend>
                1. <small id='XwY5K'></small><noframes id='XwY5K'>

                  本文介紹了std::enable_if 如何工作?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我剛剛問了這個問題:std::numeric_limits 作為條件

                  我了解 std::enable_if 將有條件地定義方法的返回類型導致方法編譯失敗的用法.

                  template類型名稱 std::enable_if<std::numeric_limits<T>::is_integer, void>::type foo(const T &bar) { isInt(bar);}

                  我不明白的是第二個參數和對 std::enable_if 的看似毫無意義的賦值,當它被聲明為模板語句的一部分時,如 Rapptz answer.

                  template::value, int>::type = 0>void foo(const T& bar) { isInt();}

                  解決方案

                  正如 40two 在評論中提到的,理解替換失敗不是錯誤是理解的先決條件std::enable_if.

                  std::enable_if 是一個專門的模板,定義為:

                  template結構 enable_if {};模板struct enable_if{ typedef T 類型;};

                  這里的關鍵在于typedef T type僅在bool Condtrue時才定義.

                  現在有了對 std::enable_if 的理解,很明顯 void foo(const T &bar) { isInt(bar);} 定義為:

                  template類型名稱 std::enable_if<std::numeric_limits<T>::is_integer, void>::type foo(const T &bar) { isInt(bar);}

                  如firda 的答案所述,= 0 是第二個模板的默認值范圍.template<typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0> 中默認的原因是兩個選項都可以用 foo<調用int >( 1 );.如果 std::enable_if 模板參數沒有被默認,調用 foo 將需要兩個模板參數,而不僅僅是 int.

                  <小時>

                  一般注意,通過明確輸入 typename std::enable_if::is_integer, void>::typevoidstd::enable_if 的默認第二個參數,如果你有 c++14 enable_if_t 是一個定義的類型,應該使用.所以返回類型應該壓縮為:std::enable_if_t::is_integer>

                  給 visual- 的用戶的特別說明-工作室 visual-studio-2013:不支持默認模板參數,因此您只能在函數返回時使用 enable_if:std::numeric_limits 作為條件

                  I just asked this question: std::numeric_limits as a Condition

                  I understand the usage where std::enable_if will define the return type of a method conditionally causing the method to fail to compile.

                  template<typename T>
                  typename std::enable_if<std::numeric_limits<T>::is_integer, void>::type foo(const T &bar) { isInt(bar); }
                  

                  What I don't understand is the second argument and the seemingly meaningless assignment to std::enable_if when it's declared as part of the template statement, as in Rapptz answer.

                  template<typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0>
                  void foo(const T& bar) { isInt(); }
                  

                  解決方案

                  As is mentioned in comment by 40two, understanding of Substitution Failure Is Not An Error is a prerequisite for understanding std::enable_if.

                  std::enable_if is a specialized template defined as:

                  template<bool Cond, class T = void> struct enable_if {};
                  template<class T> struct enable_if<true, T> { typedef T type; };
                  

                  The key here is in the fact that typedef T type is only defined when bool Cond is true.

                  Now armed with that understanding of std::enable_if it's clear that void foo(const T &bar) { isInt(bar); } is defined by:

                  template<typename T>
                  typename std::enable_if<std::numeric_limits<T>::is_integer, void>::type foo(const T &bar) { isInt(bar); }
                  

                  As mentioned in firda's answer, the = 0 is a defaulting of the second template parameter. The reason for the defaulting in template<typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0> is so that both options can be called with foo< int >( 1 );. If the std::enable_if template parameter was not defaulted, calling foo would require two template parameters, not just the int.


                  General note, this answer is made clearer by explicitly typing out typename std::enable_if<std::numeric_limits<T>::is_integer, void>::type but void is the default second parameter to std::enable_if, and if you have c++14 enable_if_t is a defined type and should be used. So the return type should condense to: std::enable_if_t<std::numeric_limits<T>::is_integer>

                  A special note for users of visual-studio prior to visual-studio-2013: Default template parameters aren't supported, so you'll only be able to use the enable_if on the function return: std::numeric_limits as a Condition

                  這篇關于std::enable_if 如何工作?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 不能)

                        <tbody id='pdBSx'></tbody>

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

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

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

                            <legend id='pdBSx'><style id='pdBSx'><dir id='pdBSx'><q id='pdBSx'></q></dir></style></legend>
                            主站蜘蛛池模板: 南溪在线-南溪招聘找工作、找房子、找对象,南溪综合生活信息门户! | 阀门智能定位器_电液动执行器_气动执行机构-赫尔法流体技术(北京)有限公司 | 产业规划_产业园区规划-产业投资选址及规划招商托管一体化服务商-中机院产业园区规划网 | 智能风向风速仪,风速告警仪,数字温湿仪,综合气象仪(气象五要素)-上海风云气象仪器有限公司 | 深圳宣传片制作_产品视频制作_深圳3D动画制作公司_深圳短视频拍摄-深圳市西典映画传媒有限公司 | 山东聚盛新型材料有限公司-纳米防腐隔热彩铝板和纳米防腐隔热板以及钛锡板、PVDF氟膜板供应商 | 爆炸冲击传感器-无线遥测传感器-航天星百科| 数控走心机-双主轴走心机厂家-南京建克| 天津拓展_天津团建_天津趣味运动会_天津活动策划公司-天津华天拓展培训中心 | X光检测仪_食品金属异物检测机_X射线检测设备_微现检测 | 网站建设-临朐爱采购-抖音运营-山东兆通网络科技 | 电销卡 防封电销卡 不封号电销卡 电话销售卡 白名单电销卡 电销系统 外呼系统 | 移动厕所租赁|移动卫生间|上海移动厕所租赁-家瑞租赁 | 全自动包装秤_全自动上袋机_全自动套袋机_高位码垛机_全自动包装码垛系统生产线-三维汉界机器(山东)股份有限公司 | 北京开业庆典策划-年会活动策划公司-舞龙舞狮团大鼓表演-北京盛乾龙狮鼓乐礼仪庆典策划公司 | 集装箱展厅-住人集装箱住宿|建筑|房屋|集装箱售楼处-山东锐嘉科技工程有限公司 | 恒湿机_除湿加湿一体机_恒湿净化消毒一体机厂家-杭州英腾电器有限公司 | 大米加工设备|大米加工机械|碾米成套设备|大米加工成套设备-河南成立粮油机械有限公司 | 工业风机_环保空调_冷风机_工厂车间厂房通风降温设备旺成服务平台 | 包塑软管|金属软管|包塑金属软管-闵彬管业 | 富森高压水枪-柴油驱动-养殖场高压清洗机-山东龙腾环保科技有限公司 | 网站建设-网站制作-网站设计-网站开发定制公司-网站SEO优化推广-咏熠软件 | 气力输送设备_料封泵_仓泵_散装机_气化板_压力释放阀-河南锐驰机械设备有限公司 | DWS物流设备_扫码称重量方一体机_快递包裹分拣机_广东高臻智能装备有限公司 | 回转窑-水泥|石灰|冶金-巩义市瑞光金属制品有限责任公司 | 铝镁锰板_铝镁锰合金板_铝镁锰板厂家_铝镁锰金属屋面板_安徽建科 | 焦作网 WWW.JZRB.COM| 一礼通 (www.yilitong.com)-企业礼品解决方案一站式服务平台 | 安德建奇火花机-阿奇夏米尔慢走丝|高维|发那科-北京杰森柏汇 | 广东成考网-广东成人高考网 | 幂简集成 - 品种超全的API接口平台, 一站搜索、试用、集成国内外API接口 | 氧氮氢联合测定仪-联测仪-氧氮氢元素分析仪-江苏品彦光电 | 拉卡拉POS机官网 - 官方直营POS机办理|在线免费领取 | 食品机械专用传感器-落料放大器-低价接近开关-菲德自控技术(天津)有限公司 | 三佳互联一站式网站建设服务|网站开发|网站设计|网站搭建服务商 赛默飞Thermo veritiproPCR仪|ProFlex3 x 32PCR系统|Countess3细胞计数仪|371|3111二氧化碳培养箱|Mirco17R|Mirco21R离心机|仟诺生物 | 一体化污水处理设备_生活污水处理设备_全自动加药装置厂家-明基环保 | 武汉宣传片制作-视频拍摄-企业宣传片公司-武汉红年影视 | 有声小说,听书,听小说资源库-听世界网 | 蓝米云-专注于高性价比香港/美国VPS云服务器及海外公益型免费虚拟主机 | 中视电广_短视频拍摄_短视频推广_短视频代运营_宣传片拍摄_影视广告制作_中视电广 | 校车_校车价格_19座幼儿园校车_幼儿园校车_大鼻子校车 |