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

    <tfoot id='K5sni'></tfoot>

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

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

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

      c++ - 如何在c ++模板中執行if else依賴類型?

      how to do an if else depending type of type in c++ template?(c++ - 如何在c ++模板中執行if else依賴類型?)
    2. <tfoot id='HOm5c'></tfoot>

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

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

              • <legend id='HOm5c'><style id='HOm5c'><dir id='HOm5c'><q id='HOm5c'></q></dir></style></legend>
                <i id='HOm5c'><tr id='HOm5c'><dt id='HOm5c'><q id='HOm5c'><span id='HOm5c'><b id='HOm5c'><form id='HOm5c'><ins id='HOm5c'></ins><ul id='HOm5c'></ul><sub id='HOm5c'></sub></form><legend id='HOm5c'></legend><bdo id='HOm5c'><pre id='HOm5c'><center id='HOm5c'></center></pre></bdo></b><th id='HOm5c'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='HOm5c'><tfoot id='HOm5c'></tfoot><dl id='HOm5c'><fieldset id='HOm5c'></fieldset></dl></div>
                  <tbody id='HOm5c'></tbody>
                本文介紹了c++ - 如何在c ++模板中執行if else依賴類型?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..
                // template specialization
                #include <iostream>
                using namespace std;
                
                // class template:
                template <class T>
                class mycontainer {
                    T element;
                  public:
                    mycontainer (T arg) {element=arg;}
                    T increase () {
                
                    //if(T.type==int)//how to do this or something similar?
                    //do this if an int
                    return ++element;
                
                    //if(T.type==char)
                     //if ((element>='a')&&(element<='z'))
                      //element+='A'-'a';
                      //return element;
                
                    }
                };
                

                我知道如何編寫模板特化并為 char 類型做一個單獨的整個類定義.

                I know how to write a template specialization and do a separate whole class def just for the char type.

                但是如果我想在一個代碼塊中處理所有事情怎么辦?

                But what if I wanted to handle everything in just one block of code?

                如何檢查 T 是 int 還是 char?

                How can I check if T is an int or a char?

                推薦答案

                你可以使用 typeid:

                if (typeid(T) == typeid(int))
                

                或者你可以使用 std::is_same 類型特征:

                Or you could use the std::is_same type trait:

                if (std::is_same<T, int>::value)
                

                這篇關于c++ - 如何在c ++模板中執行if else依賴類型?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 不能)
              • <tfoot id='OCpZH'></tfoot>
              • <i id='OCpZH'><tr id='OCpZH'><dt id='OCpZH'><q id='OCpZH'><span id='OCpZH'><b id='OCpZH'><form id='OCpZH'><ins id='OCpZH'></ins><ul id='OCpZH'></ul><sub id='OCpZH'></sub></form><legend id='OCpZH'></legend><bdo id='OCpZH'><pre id='OCpZH'><center id='OCpZH'></center></pre></bdo></b><th id='OCpZH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OCpZH'><tfoot id='OCpZH'></tfoot><dl id='OCpZH'><fieldset id='OCpZH'></fieldset></dl></div>
                <legend id='OCpZH'><style id='OCpZH'><dir id='OCpZH'><q id='OCpZH'></q></dir></style></legend>

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

                        <bdo id='OCpZH'></bdo><ul id='OCpZH'></ul>
                          <tbody id='OCpZH'></tbody>

                          主站蜘蛛池模板: 91麻豆精品国产91久久久更新资源速度超快 | 亚洲精品国产成人 | 欧美精品一区二区三区四区五区 | 羞羞视频网 | 久久精品色视频 | 综合二区| 91国内在线观看 | 一区二区三区av | 日本一二三区电影 | 国产一区二区三区四区区 | 不卡一区 | 国产精品久久久久久久久久久久 | 亚洲精品福利视频 | 久久亚洲一区二区三区四区 | 日日碰狠狠躁久久躁96avv | 亚洲精品成人免费 | 天天久久 | 黄色免费在线网址 | 亚洲成av人片在线观看 | av中文字幕在线观看 | 午夜a级理论片915影院 | 国产精品片aa在线观看 | 精品国产欧美一区二区三区成人 | 亚洲成人99 | 午夜在线精品偷拍 | 女同久久另类99精品国产 | 国产日韩欧美一区 | 国产午夜精品视频 | 97精品一区二区 | 久久精品屋 | 久久99精品久久久久久琪琪 | av日韩精品 | 欧美一区二区三区在线播放 | 一级黄色录像毛片 | 99久久婷婷 | 国产精品一区二区在线播放 | 色爱综合网 | 国产精品国产三级国产a | 国产视频观看 | 综合欧美亚洲 | 男女av|