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

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

                  問題描述

                  限時送ChatGPT賬號..

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

                  #include 模板 結構測試{靜態 int c(){靜態整數 t = 0;返回 t++;}};typedef int 句柄;int main(){std::cout <<測試<int>::c()<<std::endl;std::cout <<測試<句柄>::c()<

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

                  解決方案

                  引用 cplusplus.com,

                  <塊引用>

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

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

                  不過,正如@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 );
                  

                  這篇關于強類型定義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='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>

                          • 主站蜘蛛池模板: 国产精品一级二级 | 黄视频在线播放 | 亚洲国产成人精品女人久久久 | 中文字幕国产 | 六月激情婷婷 | 中文在线字幕免费观 | 黄色高清网站 | 亚洲久久久 | 中文字幕二区 | 欧美视频在线观看一区 | 中文字幕日韩视频 | 中文字幕综合网 | 激情导航 | 日韩视频在线免费观看 | 久久精品视| 国产成人精品免费 | 免费观看一区二区三区毛片 | 在线观看av的网站 | 日韩在线免费观看视频 | 精品久久网 | 久久都是精品 | 亚洲欧美中文字幕 | 欧美在线一区二区 | www.精品| 久久国产影院 | 亚洲一区影院 | 黄色午夜| 日韩有码av | 一区二区三区四区国产 | 91中文在线 | 亚洲永久免费视频 | 欧美大片黄 | 蜜臀久久99精品久久久久宅男 | 日韩精品久久久久久久酒店 | 久久久成人精品 | 中文字幕欧美激情 | 玖玖视频| 久操av在线 | 日韩伦理在线观看 | 久久久久久综合 | 一级a毛片|