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

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

        <legend id='XlNPI'><style id='XlNPI'><dir id='XlNPI'><q id='XlNPI'></q></dir></style></legend>

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

      1. <tfoot id='XlNPI'></tfoot>

        強類型定義

        Strong typedefs(強類型定義)
          <bdo id='XZxV6'></bdo><ul id='XZxV6'></ul>
        • <tfoot id='XZxV6'></tfoot>
            <i id='XZxV6'><tr id='XZxV6'><dt id='XZxV6'><q id='XZxV6'><span id='XZxV6'><b id='XZxV6'><form id='XZxV6'><ins id='XZxV6'></ins><ul id='XZxV6'></ul><sub id='XZxV6'></sub></form><legend id='XZxV6'></legend><bdo id='XZxV6'><pre id='XZxV6'><center id='XZxV6'></center></pre></bdo></b><th id='XZxV6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XZxV6'><tfoot id='XZxV6'></tfoot><dl id='XZxV6'><fieldset id='XZxV6'></fieldset></dl></div>

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

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

                  本文介紹了強類型定義的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  有沒有辦法制作一個類型的完整副本,以便在模板推導(dǎo)上下文中區(qū)分它們?舉個例子:

                  #include 模板 結(jié)構(gòu)測試{靜態(tài) int c(){靜態(tài)整數(shù) t = 0;返回 t++;}};typedef int 句柄;int main(){std::cout <<測試<int>::c()<<std::endl;std::cout <<測試<句柄>::c()<

                  由于 typedef 只為一個類型創(chuàng)建一個別名,這將打印 0, 1而不是所需的 0, 0.是否有任何解決方法?

                  解決方案

                  引用 cplusplus.com,

                  <塊引用>

                  請注意,既不是 typedef 也不是 using 創(chuàng)建新的不同數(shù)據(jù)類型.它們只創(chuàng)建現(xiàn)有類型的同義詞.這意味著類型上面的 myword 用 WORD 類型聲明,也可以考慮輸入無符號整數(shù);這并不重要,因為兩者實際上都是指的是同一類型.

                  由于inthandle 相同,輸出0 1 是預(yù)期的.>

                  不過,正如@interjay 建議的那樣,有一個解決方法.

                  您可以使用BOOST_STRONG_TYPEDEF.

                  BOOST_STRONG_TYPEDEF( int , handle );

                  Is there any way to make a complete copy of a type so that they can be distinguished in template deduction context? Take the example:

                  #include <iostream>
                  
                  template <typename T>
                  struct test
                  {
                      static int c()
                      { 
                          static int t = 0;
                          return t++;
                      }
                  };
                  
                  typedef int handle;
                  
                  int main()
                  {
                      std::cout << test<int>::c() << std::endl;
                      std::cout << test<handle>::c() << std::endl;
                      return 0;
                  }
                  

                  Since typedef only makes an alias for a type, this prints 0, 1 instead of the desired 0, 0. Is there any workaround for this?

                  解決方案

                  Quoting cplusplus.com,

                  Note that neither typedef nor using create new distinct data types. They only create synonyms of existing types. That means that the type of myword above, declared with type WORD, can as well be considered of type unsigned int; it does not really matter, since both are actually referring to the same type.

                  Since int and handle are one and the same, the output 0 1 is expected.

                  There's a workaround though, as @interjay suggests.

                  You can use BOOST_STRONG_TYPEDEF.

                  BOOST_STRONG_TYPEDEF( int , handle );
                  

                  這篇關(guān)于強類型定義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Why do two functions have the same address?(為什么兩個函數(shù)的地址相同?)
                  Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復(fù)制構(gòu)造的?)
                  mixing templates with polymorphism(混合模板與多態(tài)性)
                  When should I use the keyword quot;typenamequot; when using templates(我什么時候應(yīng)該使用關(guān)鍵字“typename?使用模板時)
                  Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標(biāo)準(zhǔn)庫)
                  gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數(shù)模板,而 clang 不能)

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

                    <tbody id='bXxBm'></tbody>

                  <legend id='bXxBm'><style id='bXxBm'><dir id='bXxBm'><q id='bXxBm'></q></dir></style></legend>
                    • <bdo id='bXxBm'></bdo><ul id='bXxBm'></ul>

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

                          • 主站蜘蛛池模板: 欧美一二区 | 国产不卡在线 | а_天堂中文最新版地址 | 欧美国产一区二区 | 亚洲综合一区二区三区 | 国产精品国产精品国产专区不卡 | 日韩精品一区中文字幕 | 国产精品99久久久久 | 黄色av网站在线免费观看 | av大片| 久久一日本道色综合久久 | 天堂一区二区三区 | 四虎最新 | 亚洲成人久久久 | m豆传媒在线链接观看 | 亚洲精品一区在线观看 | 国产一二区视频 | 久久精品屋 | 久久国产欧美日韩精品 | 日韩欧美日韩在线 | 亚洲国产精选 | 久久精品无码一区二区三区 | 欧美小视频在线观看 | 国产高清精品一区二区三区 | 久久亚洲一区二区三 | 精品久久久精品 | 国产99视频精品免视看9 | 日韩欧美在线观看 | 麻豆一区 | 久久狠狠 | 成人精品国产免费网站 | 国产成人精品久久二区二区91 | 草草视频在线观看 | 少妇淫片aaaaa毛片叫床爽 | 成人精品鲁一区一区二区 | 日韩欧美在线视频播放 | 国产欧美精品一区二区三区 | av片免费 | 激情五月激情综合网 | 日韩无 | 91精品国产综合久久久动漫日韩 |