pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

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

    2. <small id='VzQJD'></small><noframes id='VzQJD'>

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

      1. 依賴名稱解析命名空間 std/標準庫

        Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標準庫)

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

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

                <tbody id='LczWL'></tbody>
              • <small id='LczWL'></small><noframes id='LczWL'>

                  本文介紹了依賴名稱解析命名空間 std/標準庫的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  在回答這個問題時(最好閱讀這個重復"),我想出了以下解決運算符依賴名稱解析的解決方案:

                  While answering this SO question (better read this "duplicate"), I came up with the following solution to dependent name resolution of an operator:

                  [temp.dep.res]/1:

                  [temp.dep.res]/1:

                  在解析依賴名稱時,會考慮來自以下來源的名稱:

                  In resolving dependent names, names from the following sources are considered:

                  • 在模板定義點可見的聲明.
                  • 來自與實例化上下文 (14.6.4.1) 和定義上下文中的函數參數類型相關聯的命名空間聲明.

                  #include <iostream>
                  #include <utility>
                  
                  // this operator should be called from inside `istream_iterator`
                  std::istream& operator>>(std::istream& s, std::pair<int,int>& p)
                  {
                      s >> p.first >> p.second;
                      return s;
                  }
                  
                  // include definition of `istream_iterator` only after declaring the operator
                  // -> temp.dep.res/1 bullet 1 applies??
                  #include <iterator>
                  
                  #include <map>
                  #include <fstream>
                  
                  int main()
                  {
                      std::ifstream in("file.in");
                  
                      std::map<int, int> pp; 
                      pp.insert( std::istream_iterator<std::pair<int, int>>{in},
                                 std::istream_iterator<std::pair<int, int>>{} );
                  }
                  

                  但是 clang++ 3.2 和 g++ 4.8 沒有找到這個操作符(名稱解析).

                  But clang++ 3.2 and g++ 4.8 don't find this operator (name resolution).

                  包含難道不是定義了模板的定義點"istream_iterator?

                  Doesn't the inclusion of <iterator> define the "point of definition of the template" istream_iterator?

                  正如 Andy Prowl 指出的那樣,這與標準庫無關,而是與名稱查找(可以通過模擬具有多個 operator>> 的標準庫來證明,至少一個位于假 istream 的命名空間中).

                  As Andy Prowl points out, this has nothing to do with the Standard Library, but rather with name lookup (can be proven by mimicking the Standard Library with multiple operator>>, at least one in the namespace of the fake istream).

                  Edit2:一種解決方法,使用 [basic.lookup.argdep]/2 bullet 2

                  A workaround, using [basic.lookup.argdep]/2 bullet 2

                  #include <iostream>
                  #include <utility>
                  
                  // can include <iterator> already here,
                  // as the definition of a class template member function
                  // is only instantiated when the function is called (or explicit instantiation)
                  // (make sure there are no relevant instantiations before the definition
                  //  of the operator>> below)
                  #include <iterator>
                  
                  struct my_int
                  {
                      int m;
                      my_int() : m() {}
                      my_int(int p) : m(p) {}
                      operator int() const { return m; }
                  };
                  
                  // this operator should be called from inside `istream_iterator`
                  std::istream& operator>>(std::istream& s, std::pair<my_int,my_int>& p)
                  {
                      s >> p.first.m >> p.second.m;
                      return s;
                  }
                  
                  #include <map>
                  #include <fstream>
                  
                  int main()
                  {
                      std::ifstream in("file.in");
                  
                      std::map<int, int> pp; 
                      pp.insert( std::istream_iterator<std::pair<my_int, my_int>>{in},
                                 std::istream_iterator<std::pair<my_int, my_int>>{} );
                  }
                  

                  當然,您也可以使用自己的pair類型,只要解決方法在自定義operator>>的命名空間中引入關聯的類即可.

                  Of course, you can also use your own pair type, as long as the workaround introduces an associated class in the namespace of the custom operator>>.

                  推薦答案

                  這里的問題是你調用 operator >> 的點是在 內部的某個地方std 命名空間,參數類型所在的命名空間為 std.

                  The problem here is that the point where your call to operator >> is being made is somewhere inside the std namespace, and the namespace where the types of the arguments live is std.

                  只要編譯器可以在調用發生的命名空間或參數類型所在的命名空間(兩者都是 std 命名空間在這種情況下),無論它是否適用于重載解析(在名稱查找之后執行),它都不會費心尋找 operator > 的更多重載.> 在父命名空間中.

                  Provided the compiler can find an operator >> in either the namespace where the call occurs or the namespace where the types of the arguments live (both are the std namespace in this case), no matter whether it is viable or not for overload resolution (which is performed after name lookup), it won't bother looking for more overloads of operator >> in parent namespaces.

                  不幸的是,您的 operator >> 位于全局命名空間中,因此找不到.

                  Unfortunately, your operator >> lives in the global namespace and is, therefore, not found.

                  這篇關于依賴名稱解析命名空間 std/標準庫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?使用模板時)
                  gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數模板,而 clang 不能)
                  Strong typedefs(強類型定義)

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

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

                        • <bdo id='psqss'></bdo><ul id='psqss'></ul>
                          <tfoot id='psqss'></tfoot>
                          <legend id='psqss'><style id='psqss'><dir id='psqss'><q id='psqss'></q></dir></style></legend>
                            <tbody id='psqss'></tbody>

                            主站蜘蛛池模板: 深圳标识制作公司-标识标牌厂家-深圳广告标识制作-玟璟广告-深圳市玟璟广告有限公司 | 真空上料机(一种真空输送机)-百科 | 高柔性拖链电缆-聚氨酯卷筒电缆-柔性屏蔽电缆厂家-玖泰电缆 | 污水提升器,污水提升泵,地下室排水,增压泵,雨水泵,智能供排水控制器-上海智流泵业有限公司 | 泰州物流公司_泰州货运公司_泰州物流专线-东鑫物流公司 | 无纺布包装机|径向缠绕包装机|缠绕膜打包机-上海晏陵智能设备有限公司 | 银川美容培训-美睫美甲培训-彩妆纹绣培训-新娘化妆-学化妆-宁夏倍莱妮职业技能培训学校有限公司 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 临沂招聘网_人才市场_招聘信息_求职招聘找工作请认准【马头商标】 | 缓蚀除垢剂_循环水阻垢剂_反渗透锅炉阻垢剂_有机硫化物-郑州威大水处理材料有限公司 | 电主轴,车床电磨头,变频制动电机-博山鸿达特种电机 | 珠海网站建设_响应网站建设_珠海建站公司_珠海网站设计与制作_珠海网讯互联 | 山楂片_雪花_迷你山楂片_山楂条饼厂家-青州市丰源食品厂 | 打包箱房_集成房屋-山东佳一集成房屋有限公司 | 蒸汽热收缩机_蒸汽发生器_塑封机_包膜机_封切收缩机_热收缩包装机_真空机_全自动打包机_捆扎机_封箱机-东莞市中堡智能科技有限公司 | 展厅设计-展馆设计-专业企业展厅展馆设计公司-昆明华文创意 | 哈希余氯测定仪,分光光度计,ph在线监测仪,浊度测定仪,试剂-上海京灿精密机械有限公司 | 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 无纺布包装机|径向缠绕包装机|缠绕膜打包机-上海晏陵智能设备有限公司 | 上海刑事律师|刑事辩护律师|专业刑事犯罪辩护律师免费咨询-[尤辰荣]金牌上海刑事律师团队 | 刹车盘机床-刹车盘生产线-龙口亨嘉智能装备 | 福兰德PVC地板|PVC塑胶地板|PVC运动地板|PVC商用地板-中国弹性地板系统专业解决方案领先供应商! 福建成考网-福建成人高考网 | 矿用履带式平板车|探水钻机|气动架柱式钻机|架柱式液压回转钻机|履带式钻机-启睿探水钻机厂家 | 在线悬浮物浓度计-多参数水质在线检测仪-上海沃懋仪表科技有限公司 | 深圳侦探联系方式_深圳小三调查取证公司_深圳小三分离机构 | PCB设计,PCB抄板,电路板打样,PCBA加工-深圳市宏力捷电子有限公司 | 自动钻孔机-全自动数控钻孔机生产厂家-多米(广东)智能装备有限公司 | 万烁建筑设计院-建筑设计公司加盟,设计院加盟分公司,市政设计加盟 | 利浦顿蒸汽发生器厂家-电蒸汽发生器/燃气蒸汽发生器_湖北利浦顿热能科技有限公司官网 | ★济南领跃标识制作公司★济南标识制作,标牌制作,山东标识制作,济南标牌厂 | 新能源汽车电池软连接,铜铝复合膜柔性连接,电力母排-容发智能科技(无锡)有限公司 | pbootcms网站模板|织梦模板|网站源码|jquery建站特效-html5模板网 | 聚氨酯催化剂K15,延迟催化剂SA-1,叔胺延迟催化剂,DBU,二甲基哌嗪,催化剂TMR-2,-聚氨酯催化剂生产厂家 | 桂林腻子粉_内墙外墙抗裂砂浆腻子粉推荐广西鑫达涂料厂家供应 | 粒米特测控技术(上海)有限公司-测功机_减速机测试台_电机测试台 | 「阿尔法设计官网」工业设计_产品设计_产品外观设计 深圳工业设计公司 | 谷梁科技| 亿立分板机_曲线_锯片式_走刀_在线式全自动_铣刀_在线V槽分板机-杭州亿协智能装备有限公司 | 高考志愿规划师_高考规划师_高考培训师_高报师_升学规划师_高考志愿规划师培训认证机构「向阳生涯」 | 365文案网_全网创意文案句子素材站 | 地磅-地秤-江阴/无锡地磅-江阴天亿计量设备有限公司_ | 书法培训-高考书法艺考培训班-山东艺霖书法培训凭实力挺进央美 |