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

  1. <tfoot id='IxneN'></tfoot>
  2. <legend id='IxneN'><style id='IxneN'><dir id='IxneN'><q id='IxneN'></q></dir></style></legend>

      <bdo id='IxneN'></bdo><ul id='IxneN'></ul>

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

    2. <i id='IxneN'><tr id='IxneN'><dt id='IxneN'><q id='IxneN'><span id='IxneN'><b id='IxneN'><form id='IxneN'><ins id='IxneN'></ins><ul id='IxneN'></ul><sub id='IxneN'></sub></form><legend id='IxneN'></legend><bdo id='IxneN'><pre id='IxneN'><center id='IxneN'></center></pre></bdo></b><th id='IxneN'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='IxneN'><tfoot id='IxneN'></tfoot><dl id='IxneN'><fieldset id='IxneN'></fieldset></dl></div>
    3. 為什么 std::function 的初始化程序必須是可復制構

      Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復制構造的?)

        <tbody id='f50xy'></tbody>

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

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

                本文介紹了為什么 std::function 的初始化程序必須是可復制構造的?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                根據http://en.cppreference.com/w/cpp/utility/functional/function/function,初始化器的類型,即形式(5)中的F,應滿足CopyConstructible的要求.我不太明白這個.為什么 F 不能只是 MoveConstructible?

                According to http://en.cppreference.com/w/cpp/utility/functional/function/function, the type of the initializer, i.e., F in form (5), should meet the requirements of CopyConstructible. I don't quite get this. Why is it not OK for F to be just MoveConstructible?

                推薦答案

                std::function 在內部使用類型擦除,因此 F 必須是可復制構造的,即使您使用的特定 std::function 對象從未被復制.

                std::function uses type erasure internally, so F has to be CopyConstructible even if the particular std::function object you are using is never copied.

                類型擦除工作原理的簡化:

                A simplification on how type erasure works:

                class Function
                {
                    struct Concept {
                        virtual ~Concept() = default;
                        virtual Concept* clone() const = 0;
                        //...
                    }
                
                    template<typename F>
                    struct Model final : Concept {
                
                        explicit Model(F f) : data(std::move(f)) {}
                        Model* clone() const override { return new Model(*this); }
                        //...
                
                        F data;
                    };
                
                    std::unique_ptr<Concept> object;
                
                public:
                    template<typename F>
                    explicit Function(F f) : object(new Model<F>(std::move(f))) {}
                
                    Function(Function const& that) : object(that.object->clone()) {}
                    //...
                
                };
                

                您必須能夠生成 Model::clone(),這會強制 F 為 CopyConstructible.

                You have to be able to generate Model<F>::clone(), which forces F to be CopyConstructible.

                這篇關于為什么 std::function 的初始化程序必須是可復制構造的?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                Why do two functions have the same address?(為什么兩個函數的地址相同?)
                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 不能)
                Strong typedefs(強類型定義)
                <legend id='ID4RL'><style id='ID4RL'><dir id='ID4RL'><q id='ID4RL'></q></dir></style></legend>

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

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

                    • <bdo id='ID4RL'></bdo><ul id='ID4RL'></ul>

                        1. 主站蜘蛛池模板: 成人欧美日韩一区二区三区 | 91精品国产综合久久精品 | 精品国产欧美日韩不卡在线观看 | 国产亚洲精品美女久久久久久久久久 | 欧美日韩激情 | 亚洲国产精品久久久久久 | 在线91| 日本公妇乱淫xxxⅹ 国产在线不卡 | 成人欧美一区二区三区黑人孕妇 | 免费一级片 | 懂色av蜜桃av | 日韩久久网 | 在线免费观看成年人视频 | 精品国产伦一区二区三区观看体验 | 精品成人佐山爱一区二区 | 日韩精品成人一区二区三区视频 | 欧美日韩在线播放 | julia中文字幕久久一区二区 | 播放一级毛片 | 精品国产一区二区国模嫣然 | 成人国产免费视频 | 国产欧美日韩精品在线观看 | 91精品国产高清一区二区三区 | 精品国产网 | 日韩国产在线观看 | 国产日韩精品在线 | 天堂久久网 | 99久久99| 一区二区精品视频 | 久久久久久国产精品免费免费狐狸 | 欧美成视频 | 国产精品美女久久久久aⅴ国产馆 | 色综合欧美 | 看特级黄色片 | 日日夜夜精品视频 | 日韩av福利在线观看 | 天天干天天草 | 成人午夜视频在线观看 | 欧美午夜精品理论片a级按摩 | 国产乱码精品一区二区三区五月婷 | 97超碰在线播放 |