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

                          主站蜘蛛池模板: 日一区二区 | 欧美精品在线一区二区三区 | 综合在线视频 | 一本岛道一二三不卡区 | 九九国产在线观看 | 日韩av啪啪网站大全免费观看 | 日韩视频国产 | 欧美亚洲国产日韩 | 都市激情亚洲 | 精品一区在线免费观看 | 免费在线一区二区三区 | 99re99| 日韩精品在线网站 | 天堂久久天堂综合色 | 色成人免费网站 | 久久久久久久久毛片 | 国产精品视频一区二区三区四区国 | 成人免费视频在线观看 | 欧美日韩黄| 久久中文字幕一区 | 91久久久www播放日本观看 | www.青青草| 狠狠色香婷婷久久亚洲精品 | 高清国产一区二区 | 国产免费一区二区 | 亚洲va欧美va天堂v国产综合 | 在线观看国产视频 | 自拍偷拍第一页 | 国产欧美一区二区三区日本久久久 | 亚洲精品久久久久久国产精华液 | 先锋资源亚洲 | 成人精品在线观看 | 好好的日在线视频 | 午夜精品一区二区三区免费视频 | 少妇久久久| 中文字幕亚洲在线 | 精品国产一区二区三区性色av | 国产视频欧美 | 精品成人一区 | 欧美一区二区三区日韩 | 日日摸日日碰夜夜爽亚洲精品蜜乳 |