久久久久久久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>

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

        Fallback variadic constructor - why does this work?(后備可變參數(shù)構造函數(shù) - 為什么這有效?)
          <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'>

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

                  問題描述

                  限時送ChatGPT賬號..

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

                  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&&... ) { }
                  

                  我的意思是說,我嘗試過并驚訝地發(fā)現(xiàn)它確實有效.它編譯并完成了我對 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它得到了錯誤的答案.模板代碼中的任何類型的緩存都可能導致錯誤——嘗試在調用構造函數(shù)后在相同的參數(shù)上打印 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.

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

                  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 違規(guī)——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.

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

                  這篇關于后備可變參數(shù)構造函數(shù) - 為什么這有效?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Why do two functions have the same address?(為什么兩個函數(shù)的地址相同?)
                  Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復制構造的?)
                  mixing templates with polymorphism(混合模板與多態(tài)性)
                  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 可以編譯可變參數(shù)模板,而 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. 主站蜘蛛池模板: 中文字幕一区在线观看 | 狠狠做深爱婷婷综合一区 | 久久久久女人精品毛片九一 | 国产黄色免费观看 | 国产精品成人国产乱一区 | 97国产在线观看 | 激情视频网 | 国产精品久久久久久久久久 | 亚洲综合图片区 | 日韩一级片 | 在线观看91 | 黄色成人免费视频 | 精品视频国产 | 国产日韩视频 | aa久久 | 中文字幕免费在线 | 明日边缘 | 欧美精品一二三 | 91精品久久久久久久久久 | 91国内视频 | 日韩精品久久 | 黄色大片免费观看 | 欧美精品影院 | 免费av片| 国产三区在线观看 | 亚洲精品久久久蜜桃 | 成年在线观看 | 日本中文字幕一区 | 欧美日韩一区二 | 91福利视频导航 | 午夜无遮挡 | 成年人av| 日韩一区二区三区四区 | 中文字幕永久免费 | 日韩精品黄 | 五月婷婷丁香花 | 国产午夜免费 | 日本毛片在线观看 | 精品久久久久久久久久久 | 成人精品在线观看 | 欧美成人极品 |