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

                問題描述

                限時送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="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>

                          主站蜘蛛池模板: 欧美一级免费 | 午夜小电影 | 精品一区二区三区四区在线 | 精久久| av网站在线看 | 自拍偷拍3p| 91麻豆精品国产91久久久更新资源速度超快 | 插插宗合网 | 日韩精品一区二区三区在线播放 | 国产一二区视频 | 91国产视频在线 | www.日本精品 | 亚洲中午字幕 | 国产福利二区 | 一级黄色片在线看 | 亚洲色图在线观看 | 91亚洲一区 | 免费一级片| 国产成人精品一区二区三区在线 | 丝袜 亚洲 另类 欧美 综合 | 91电影| 日韩中文字幕区 | 综合久久综合久久 | 特a毛片 | 国产精品国产馆在线真实露脸 | 97天天干| 性色av一区| 精品成人在线视频 | 欧美自拍另类 | 久草视频在线播放 | 国产精品视频一区二区三区 | 一级片网址 | 欧美一区二区在线免费观看 | 日韩毛片在线免费观看 | 一区免费观看 | 国产一级在线 | 中文字幕高清av | 国产欧美三区 | 91在线看片 | 人人鲁人人莫人人爱精品 | 欧美日韩高清一区二区三区 |