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

    <bdo id='v5iLP'></bdo><ul id='v5iLP'></ul>

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

    <tfoot id='v5iLP'></tfoot>

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

      回歸虛無?

      Returning a void?(回歸虛無?)
          <bdo id='1pmdD'></bdo><ul id='1pmdD'></ul>
        • <i id='1pmdD'><tr id='1pmdD'><dt id='1pmdD'><q id='1pmdD'><span id='1pmdD'><b id='1pmdD'><form id='1pmdD'><ins id='1pmdD'></ins><ul id='1pmdD'></ul><sub id='1pmdD'></sub></form><legend id='1pmdD'></legend><bdo id='1pmdD'><pre id='1pmdD'><center id='1pmdD'></center></pre></bdo></b><th id='1pmdD'></th></span></q></dt></tr></i><div class="fbxx5b7" id='1pmdD'><tfoot id='1pmdD'></tfoot><dl id='1pmdD'><fieldset id='1pmdD'></fieldset></dl></div>

              <small id='1pmdD'></small><noframes id='1pmdD'>

              <tfoot id='1pmdD'></tfoot>

            • <legend id='1pmdD'><style id='1pmdD'><dir id='1pmdD'><q id='1pmdD'></q></dir></style></legend>

                  <tbody id='1pmdD'></tbody>
                本文介紹了回歸虛無?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我不明白為什么這段代碼編譯沒有錯誤:

                I do not understand why this code compiles without error:

                #include <iostream>
                
                template <class T>
                struct Test
                {
                    static constexpr T f() {return T();} 
                };
                
                int main()
                {
                    Test<void> test;
                    test.f(); // Why not an error?
                    return 0;
                }
                

                按照標準是可以的,還是編譯器的容忍度?

                Is it ok according to the standard, or is it a compiler tolerance?

                推薦答案

                這看起來有效 草案 C++11 標準,如果我們查看 5.2.3 部分 顯式類型轉換(功能符號)em> 段落 2 說(強調我的):

                This looks valid by the draft C++11 standard, if we look at section 5.2.3 Explicit type conversion (functional notation) paragraph 2 says (emphasis mine):

                表達式 T(),其中 T 是簡單類型說明符或非數組完整對象類型的類型名稱說明符 或(可能是 cv 限定的)void 類型,創建指定類型,其值是由值初始化產生的(8.5) 類型 T 的對象;void() 沒有初始化案例.[...]

                The expression T(), where T is a simple-type-specifier or typename-specifier for a non-array complete object type or the (possibly cv-qualified) void type, creates a prvalue of the specified type, whose value is that produced by value-initializing (8.5) an object of type T; no initialization is done for the void() case.[...]

                措辭非常相似 pre C++11 也是如此.

                the wording is pretty similar pre C++11 as well.

                這在 constexpr 中沒問題,盡管 7.1.53 說:

                This okay in a constexpr even though section 7.1.5 paragraph 3 says:

                constexpr 函數的定義應滿足以下條件約束:

                The definition of a constexpr function shall satisfy the following constraints:

                并包括此項目符號:

                它的返回類型應該是一個文字類型;

                its return type shall be a literal type;

                void 不是 C++11 中的 文字,如 3.9 部分 10但是如果我們再看6段,它給出了一個適合這種情況的例外,它說:

                and void is not a literal in C++11 as per section 3.9 paragraph 10, but if we then look at paragraph 6 it gives an exception that fits this case, it says:

                如果一個 constexpr 函數的實例化模板特化類模板的模板或成員函數將無法滿足constexpr 函數或 constexpr 構造函數的要求,該特化不是 constexpr 函數或 constexpr構造函數.[ 注意:如果函數是成員函數,它將仍然是常量,如下所述.—end note ] 如果沒有專業化模板將產生一個 constexpr 函數或 constexpr構造函數,程序格式錯誤;無需診斷.

                If the instantiated template specialization of a constexpr function template or member function of a class template would fail to satisfy the requirements for a constexpr function or constexpr constructor, that specialization is not a constexpr function or constexpr constructor. [ Note: If the function is a member function it will still be const as described below. —end note ] If no specialization of the template would yield a constexpr function or constexpr constructor, the program is ill-formed; no diagnostic required.

                正如凱西在C++14 草案標準 void 是一個文字,這是 3.9 Types10 說:

                As Casey noted in the C++14 draft standard void is a literal, this is section 3.9 Types paragraph 10 says:

                一個類型是文字類型,如果它是:

                A type is a literal type if it is:

                并包括:

                ——無效;或

                這篇關于回歸虛無?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 不能)
                • <bdo id='QYvHU'></bdo><ul id='QYvHU'></ul>

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

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

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

                          主站蜘蛛池模板: 隐形纱窗|防护纱窗|金刚网防盗纱窗|韦柏纱窗|上海青木装潢制品有限公司|纱窗国标起草单位 | 超声波破碎仪-均质乳化机(供应杭州,上海,北京,广州,深圳,成都等地)-上海沪析实业有限公司 | 雨燕360体育免费直播_雨燕360免费NBA直播_NBA篮球高清直播无插件-雨燕360体育直播 | 北京软件开发_软件开发公司_北京软件公司-北京宜天信达软件开发公司 | 帽子厂家_帽子工厂_帽子定做_义乌帽厂_帽厂_制帽厂 | 生鲜配送系统-蔬菜食材配送管理系统-连锁餐饮订货配送软件-挪挪生鲜供应链管理软件 | 卧涛科技有限公司科技项目申报公司|高新技术企业申报|专利申请 | 铝合金脚手架厂家-专注高空作业平台-深圳腾达安全科技 | 带式压滤机_污泥压滤机_污泥脱水机_带式过滤机_带式压滤机厂家-河南恒磊环保设备有限公司 | 蓄电池在线监测系统|SF6在线监控泄露报警系统-武汉中电通电力设备有限公司 | 螺旋压榨机-刮泥机-潜水搅拌机-电动泥斗-潜水推流器-南京格林兰环保设备有限公司 | 电动球阀_不锈钢电动球阀_电动三通球阀_电动调节球阀_上海湖泉阀门有限公司 | 北京工业设计公司-产品外观设计-产品设计公司-千策良品工业设计 北京翻译公司-专业合同翻译-医学标书翻译收费标准-慕迪灵 | 巨野月嫂-家政公司-巨野县红墙安康母婴护理中心 | 湖南自考_湖南自学考试网| 一体化预制泵站-一体化提升泵站-一体化泵站厂家-山东康威环保 | 马尔表面粗糙度仪-MAHR-T500Hommel-Mitutoyo粗糙度仪-笃挚仪器 | 紫外可见光分光度计-紫外分光度计-分光光度仪-屹谱仪器制造(上海)有限公司 | 蜗轮丝杆升降机-螺旋升降机-丝杠升降机厂家-润驰传动 | 广州市哲铭油墨涂料有限公司,水性漆生产研发基地| 深圳高新投三江工业消防解决方案提供厂家_服务商_园区智慧消防_储能消防解决方案服务商_高新投三江 | 上海刑事律师|刑事辩护律师|专业刑事犯罪辩护律师免费咨询-[尤辰荣]金牌上海刑事律师团队 | 三佳互联一站式网站建设服务|网站开发|网站设计|网站搭建服务商 赛默飞Thermo veritiproPCR仪|ProFlex3 x 32PCR系统|Countess3细胞计数仪|371|3111二氧化碳培养箱|Mirco17R|Mirco21R离心机|仟诺生物 | 冷却塔降噪隔音_冷却塔噪声治理_冷却塔噪音处理厂家-广东康明冷却塔降噪厂家 | 伸缩器_伸缩接头_传力接头-巩义市润达管道设备制造有限公司 | WTB5光栅尺-JIE WILL磁栅尺-B60数显表-常州中崴机电科技有限公司 | IP检测-检测您的IP质量| 钢格板|镀锌钢格板|热镀锌钢格板|格栅板|钢格板|钢格栅板|热浸锌钢格板|平台钢格板|镀锌钢格栅板|热镀锌钢格栅板|平台钢格栅板|不锈钢钢格栅板 - 专业钢格板厂家 | 楼梯定制_楼梯设计施工厂家_楼梯扶手安装制作-北京凌步楼梯 | 活性氧化铝球|氧化铝干燥剂|分子筛干燥剂|氢氧化铝粉-淄博同心材料有限公司 | 耐高温硅酸铝板-硅酸铝棉保温施工|亿欧建设工程 | HYDAC过滤器,HYDAC滤芯,现货ATOS油泵,ATOS比例阀-东莞市广联自动化科技有限公司 | 济南展厅设计施工_数字化展厅策划设计施工公司_山东锐尚文化传播有限公司 | 安平县鑫川金属丝网制品有限公司,声屏障,高速声屏障,百叶孔声屏障,大弧形声屏障,凹凸穿孔声屏障,铁路声屏障,顶部弧形声屏障,玻璃钢吸音板 | 蒜肠网-动漫,二次元,COSPLAY,漫展以及收藏型模型,手办,玩具的新媒体.(原变形金刚变迷TF圈) | 雨燕360体育免费直播_雨燕360免费NBA直播_NBA篮球高清直播无插件-雨燕360体育直播 | 云南外加剂,云南速凝剂,云南外加剂代加工-普洱澜湄新材料科技有限公司 | PU树脂_水性聚氨酯树脂_聚氨酯固化剂_聚氨酯树脂厂家_宝景化工 | 杭州标识标牌|文化墙|展厅|导视|户内外广告|发光字|灯箱|铭阳制作公司 - 杭州标识标牌|文化墙|展厅|导视|户内外广告|发光字|灯箱|铭阳制作公司 | 北京成考网-北京成人高考网 | 艺术涂料_进口艺术涂料_艺术涂料加盟_艺术涂料十大品牌 -英国蒙太奇艺术涂料 |