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

<tfoot id='TEUkI'></tfoot>
      • <bdo id='TEUkI'></bdo><ul id='TEUkI'></ul>

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

      1. <small id='TEUkI'></small><noframes id='TEUkI'>

        <legend id='TEUkI'><style id='TEUkI'><dir id='TEUkI'><q id='TEUkI'></q></dir></style></legend>

        后備可變參數構造函數 - 為什么這有效?

        Fallback variadic constructor - why does this work?(后備可變參數構造函數 - 為什么這有效?)
          <tbody id='SpBfL'></tbody>
        <legend id='SpBfL'><style id='SpBfL'><dir id='SpBfL'><q id='SpBfL'></q></dir></style></legend>

          <tfoot id='SpBfL'></tfoot>

                • <bdo id='SpBfL'></bdo><ul id='SpBfL'></ul>
                • <i id='SpBfL'><tr id='SpBfL'><dt id='SpBfL'><q id='SpBfL'><span id='SpBfL'><b id='SpBfL'><form id='SpBfL'><ins id='SpBfL'></ins><ul id='SpBfL'></ul><sub id='SpBfL'></sub></form><legend id='SpBfL'></legend><bdo id='SpBfL'><pre id='SpBfL'><center id='SpBfL'></center></pre></bdo></b><th id='SpBfL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='SpBfL'><tfoot id='SpBfL'></tfoot><dl id='SpBfL'><fieldset id='SpBfL'></fieldset></dl></div>
                • <small id='SpBfL'></small><noframes id='SpBfL'>

                  本文介紹了后備可變參數構造函數 - 為什么這有效?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  在回答這個問題時,關于嘗試構造一個可變參數轉發引用構造函數,只有在沒有其他構造函數時才應調用該構造函數有效的.也就是說,如果有:

                  In answering this question about trying to construct a variadic forwarding reference constructor that should only be called if no other constructor is valid. That is, if there was a:

                  C(const char*, size_t) { }                     // 1
                  template <typename... T, ???> C(T&&... ) { }   // 2
                  

                  我們希望 C c1{"abc", 2}; 調用 (1),盡管需要轉換,但是 C c2{1, 2, 3}; 調用 (2),因為 (1) 不適用.

                  We'd want C c1{"abc", 2}; to call (1), despite the required conversion, but C c2{1, 2, 3}; to call (2), as (1) cannot apply.

                  我提出了以下解決方案:

                  I proposed the following solution:

                  template <typename... T,
                            typename = std::enable_if_t<!std::is_constructible<C, T&&...>::value>
                             >
                  C(T&&... ) { }
                  

                  我的意思是說,我嘗試過并驚訝地發現它確實有效.它編譯并完成了我對 gcc 和 clang 的期望.但是,我無法解釋為什么它起作用,或者即使它實際上應該起作用,而且 gcc 和 clang 都特別包容.是嗎?為什么?

                  And by proposed, I mean, I tried it and was surprised to discover that it actually works. It compiles and does exactly what I had hoped for on both gcc and clang. However, I am at a loss to explain why it works or even if it's actually supposed to work and gcc and clang are both just being particularly accommodating. Is it? Why?

                  推薦答案

                  你的代碼的問題是我們只是在一個上下文中實例化了 is_constructible它得到了錯誤的答案.模板代碼中的任何類型的緩存都可能導致錯誤——嘗試在調用構造函數后在相同的參數上打印 is_constructible!很可能會弄錯.

                  The issue with your code is that we just instantiated is_constructible in a context where it gets the answer wrong. Any kind of caching in the template code is likely to result in bugs -- try printing is_constructible on the same parameters after you call the constructor! It is likely to get it wrong.

                  現場示例,說明如何出錯.請注意,它聲稱 C 不能從 int& 構造,盡管在前一行已經這樣做了.

                  Live example of how it can go wrong. Notice it claims C cannot be constructed from an int&, despite having done so on the previous line.

                  struct C {
                    C(const char*, size_t) {}
                    template <class... Ts,
                      typename = std::enable_if_t<!std::is_constructible<C, Ts&&...>::value>
                    >
                    C(Ts&&... ) { }
                  };
                  
                  int main() {
                    int a = 0;
                    C x{a};
                    std::cout << std::is_constructible<C, int&>{} << '
                  ';
                  }
                  

                  糟糕.

                  我懷疑這可能是 ODR 違規——is_constructible 的兩個定義在不同的位置有不同的類型?或者也許不是.

                  I suspect this might be an ODR violation -- the two definitions of is_constructible have different types at different spots? Or maybe not.

                  沒有這個問題的原始問題的解決方案也貼出來了.

                  這篇關于后備可變參數構造函數 - 為什么這有效?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='dhcQq'></tbody>
                  • <bdo id='dhcQq'></bdo><ul id='dhcQq'></ul>

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

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

                            <legend id='dhcQq'><style id='dhcQq'><dir id='dhcQq'><q id='dhcQq'></q></dir></style></legend>
                          1. 主站蜘蛛池模板: 精品久久久精品 | 国产精品视频中文字幕 | 国产精品久久亚洲 | 免费国产视频在线观看 | 国产精品亚洲一区二区三区在线观看 | 国产精品久久久乱弄 | 99re在线视频观看 | 日本不卡一区二区三区 | 91视频进入 | 免费久久99精品国产婷婷六月 | 久草网在线视频 | 国产激情在线观看视频 | 国产精品久久久久久久午夜 | 伊人性伊人情综合网 | 日韩一区二区三区在线 | 国产综合在线视频 | 91亚洲精品久久久电影 | 国产精品精品视频一区二区三区 | 亚洲欧美日韩中文在线 | 亚洲欧洲综合av | 日本一区视频在线观看 | 天堂网中文字幕在线观看 | 羞羞视频免费观看入口 | 国产三区av | 成人天堂噜噜噜 | 毛片站| 免费一级做a爰片久久毛片潮喷 | 羞羞色视频| 亚洲精品一区二区在线观看 | 天天天操操操 | 亚洲欧美v| 久久久久国产一区二区三区 | 中文字幕av网| 91精品国产麻豆 | 日日噜噜噜夜夜爽爽狠狠视频, | 搞黄网站在线观看 | 蜜桃毛片 | 国产羞羞视频在线观看 | 亚洲精品久久久 | 黄色在线观看 | 北条麻妃视频在线观看 |