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

    <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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>
                本文介紹了回歸虛無?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時(shí)送ChatGPT賬號(hào)..

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

                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;
                }
                

                按照標(biāo)準(zhǔn)是可以的,還是編譯器的容忍度?

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

                推薦答案

                這看起來有效 草案 C++11 標(biāo)準(zhǔn),如果我們查看 5.2.3 部分 顯式類型轉(zhuǎn)換(功能符號(hào))em> 段落 2 說(強(qiáng)調(diào)我的):

                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):

                表達(dá)式 T(),其中 T 是簡單類型說明符或非數(shù)組完整對(duì)象類型的類型名稱說明符 或(可能是 cv 限定的)void 類型,創(chuàng)建指定類型,其值是由值初始化產(chǎn)生的(8.5) 類型 T 的對(duì)象;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 函數(shù)的定義應(yīng)滿足以下條件約束:

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

                并包括此項(xiàng)目符號(hào):

                它的返回類型應(yīng)該是一個(gè)文字類型;

                its return type shall be a literal type;

                void 不是 C++11 中的 文字,如 3.9 部分 10但是如果我們?cè)倏?em>6段,它給出了一個(gè)適合這種情況的例外,它說:

                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:

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

                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 草案標(biāo)準(zhǔn) void 是一個(gè)文字,這是 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:

                一個(gè)類型是文字類型,如果它是:

                A type is a literal type if it is:

                并包括:

                ——無效;或

                這篇關(guān)于回歸虛無?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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 不能)
                • <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="qwawimqqmiuu" 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>

                          主站蜘蛛池模板: 亚洲人成人一区二区在线观看 | 色播久久| 美女黄18岁以下禁止观看 | 亚洲一级二级三级 | 午夜一区二区三区在线观看 | 91精品国产综合久久精品 | 亚洲成人一区二区 | 一本色道久久综合亚洲精品高清 | 天天操天天干天天透 | 亚洲一区二区三区免费观看 | 日韩精品一区二区三区免费观看 | 久久国产一区二区三区 | 亚洲一区二区在线播放 | 在线免费观看欧美 | 欧美日韩在线观看一区二区三区 | 精品国产91亚洲一区二区三区www | 久久久女女女女999久久 | 成av在线 | 亚洲一区二区三区四区五区中文 | 色婷婷国产精品综合在线观看 | 欧美久久久久久久久 | 狠狠艹 | 亚洲视频一 | 亚洲一区二区在线播放 | 欧美a在线看 | 国产一区二区三区精品久久久 | 正在播放国产精品 | 成人免费视频在线观看 | 国产成人av免费看 | 欧美日韩综合视频 | 91一区二区在线观看 | 成人在线视频网 | 亚洲欧洲在线看 | 亚洲精品久久嫩草网站秘色 | 亚洲精品国产第一综合99久久 | 澳门永久av免费网站 | 欧美精品成人一区二区三区四区 | 日本视频在线 | 91国内精品久久 | 亚洲天堂久久 | 成人久久久 |