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

                問題描述

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

                我不明白為什么這段代碼編譯沒有錯(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)換(功能符號)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ù)組完整對象類型的類型名稱說明符 或(可能是 cv 限定的)void 類型,創(chuàng)建指定類型,其值是由值初始化產(chǎn)生的(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 函數(shù)的定義應(yīng)滿足以下條件約束:

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

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

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

                its return type shall be a literal type;

                void 不是 C++11 中的 文字,如 3.9 部分 10但是如果我們再看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)于回歸虛無?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 不能)
                • <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>

                          主站蜘蛛池模板: 在线a| 国产成人在线免费观看 | 日韩午夜在线观看 | 一色桃子av | 亚洲欧美日韩另类 | 国产69精品久久久久久 | 性欧美精品 | 欧美在线一级 | 好色网站| 黄色免费网站视频 | 亚洲一区二区三区在线 | 伊人春色av | 亚洲成人欧美 | 久久精品一区二区三区不卡牛牛 | 日韩毛片网站 | 午夜影院在线 | 日韩精品福利 | 激情久久久 | 一区二区三区免费 | 亚洲一区在线观看视频 | 午夜丁香| 久久久黄色 | 在线免费看黄网站 | 久久久久久久综合 | 日本精品中文字幕 | 久草热视频 | 日韩av成人在线 | 亚洲精品福利视频 | 免费看黄色一级片 | 成人免费看片在线观看 | 欧美区在线 | 91精品国产色综合久久不卡98 | 亚洲高清在线视频 | 国产理论片在线观看 | 中文字幕伊人 | 国产第一福利 | 国产精品美女久久久久久久久 | 国产三级做爰高清在线 | 国产一区精品在线 | 俄罗斯毛片 | 国产美女自拍视频 |