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

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

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

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

      如何測試類 B 是否派生自類的模板族

      How to test whether class B is derived from template family of classes(如何測試類 B 是否派生自類的模板族)
      <legend id='mTC1K'><style id='mTC1K'><dir id='mTC1K'><q id='mTC1K'></q></dir></style></legend>
      • <bdo id='mTC1K'></bdo><ul id='mTC1K'></ul>
        1. <small id='mTC1K'></small><noframes id='mTC1K'>

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

          <tfoot id='mTC1K'></tfoot>

              <tbody id='mTC1K'></tbody>
              • 本文介紹了如何測試類 B 是否派生自類的模板族的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                如何在編譯時測試B類是否是從std::vector派生的?

                How to test at compile time whether class B is derived from std::vector?

                template<class A>
                struct is_derived_from_vector {
                  static const bool value = ????;
                };
                

                如何在編譯時測試B類是否派生自模板族?

                How to test at compile time whether class B is derived from template family?

                template<class A, template< class > class Family>
                struct is_derived_from_template {
                  static const bool value = ????;
                };
                

                使用:

                template<class T> struct X {};
                
                struct A : X<int> {}
                struct B : std::vector<char> {}
                struct D : X<D> {}
                
                int main() {
                   std::cout << is_derived_from_template<A, X>::value << std::endl; // true
                   std::cout << is_derived_from_template<D, X>::value << std::endl; // true
                   std::cout << is_derived_from_vector<A>::value << std::endl; // false
                   std::cout << is_derived_from_vector<B>::value << std::endl; // true
                }
                

                推薦答案

                試試這個:

                #include <type_traits>
                
                template <typename T, template <typename> class Tmpl>  // #1 see note
                struct is_derived
                {
                    typedef char yes[1];
                    typedef char no[2];
                
                    static no & test(...);
                
                    template <typename U>
                    static yes & test(Tmpl<U> const &);
                
                    static bool const value = sizeof(test(std::declval<T>())) == sizeof(yes);
                };
                

                用法:

                #include <iostream>
                
                template<class T> struct X {};
                
                struct A : X<int> {};
                
                int main()
                {
                    std::cout << is_derived<A, X>::value << std::endl;
                    std::cout << is_derived<int, X>::value << std::endl;
                }
                

                注意:在標記為 #1 的行中,您還可以讓您的 trait 接受任何 模板,該模板至少有一個,但可能writint 的更多類型參數:

                Note: In the line marked #1, you could also make your trait accept any template that has at least one, but possibly more type arguments by writint:

                template <typename, typename...> class Tmpl
                

                這篇關于如何測試類 B 是否派生自類的模板族的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 不能)

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

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

                        <legend id='y6R1a'><style id='y6R1a'><dir id='y6R1a'><q id='y6R1a'></q></dir></style></legend>
                          <tbody id='y6R1a'></tbody>

                          <bdo id='y6R1a'></bdo><ul id='y6R1a'></ul>
                        • 主站蜘蛛池模板: 精品一区二区久久久久久久网站 | 国产精品日韩高清伦字幕搜索 | 亚洲精品视频导航 | 中文字幕精品视频在线观看 | 五月天婷婷久久 | 久久精彩视频 | 日韩欧美网 | 人人天天操 | www.99热这里只有精品 | 亚洲精品国产电影 | 日韩在线电影 | 精品国产一区二区三区性色 | 九九久久精品视频 | 久操伊人| 亚洲综合一区二区三区 | 激情在线视频网站 | 欧美激情亚洲激情 | 99热这里| 91热在线| 久久一日本道色综合久久 | 人妖无码 | 黄色成人在线观看 | 91精品国产乱码久久久久久久久 | 国产精品色av | 精品视频在线观看 | 日日爱夜夜操 | 色成人免费网站 | 一区二区三区亚洲 | 电影91久久久 | 黄色成人免费在线观看 | 亚洲在线一区二区 | 殴美成人在线视频 | 久久com | 国产在线高清 | 蜜臀久久99精品久久久久久宅男 | 99国产精品99久久久久久粉嫩 | 国产精品99精品久久免费 | 亚洲国产中文字幕 | 国产精品国产三级国产aⅴ无密码 | 97精品超碰一区二区三区 | 日韩欧美在线播放 |