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

      <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" 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>

                            主站蜘蛛池模板: 精品免费视频一区二区 | 午夜精品久久久久久久久久久久 | 黑人巨大精品欧美一区二区免费 | 一区中文字幕 | 欧美日韩中文字幕在线 | 国产日韩一区二区 | 国产精品一区一区三区 | 国产精品日韩一区二区 | 天天影视网天天综合色在线播放 | 亚洲激情在线观看 | 亚洲国产成人精品久久 | 99re99| 99在线精品视频 | 三级视频在线观看电影 | 男女羞羞视频免费看 | 欧美中文字幕一区二区 | 亚洲一区二区三区桃乃木香奈 | 久草视频2| 国产日韩欧美中文字幕 | 成人免费在线电影 | 欧美一级片在线看 | 日本天堂视频在线观看 | 91成人在线视频 | 成人免费视频一区 | 欧美日韩亚洲国产 | 日韩午夜在线观看 | 黄视频网站免费观看 | 国产精品v| 精品视频一二区 | 欧产日产国产精品视频 | 亚洲视频中文字幕 | 国产wwwcom | 国产精品免费大片 | 视频在线一区二区 | 国产高清一二三区 | 国产精品免费一区二区三区四区 | 国产午夜影院 | 国产一区三区在线 | 日韩在线综合网 | 91一区二区三区 | 日韩视频一区二区 |