• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            為了方便顯示map而自定義的兩個函數,出現了一個詭異的問題,感謝jinq????@163.com告之解決方法,但是我對問題的原因還是不太清楚.

            #include <map>
            #include <string>
            #include <iterator>
            #include <iostream>

            using namespace std;
            namespace std    
            {    
                 //如果不將該函數放入名字空間std則使用ostream_iterator不能通過編譯
                 //但是可以直接用cout輸出pair

                template<class _Elem,class _Traits,class K,class V>
                basic_ostream<_Elem,_Traits>& operator<<(
                    basic_ostream<_Elem,_Traits>& s
                    ,
                    const pair<K,V>& p
                    )
                {
                    return s<<p.first<<" : "<<p.second;
                }

            }

            template<class _Elem,class _Traits,class K,class V>
            basic_ostream<_Elem,_Traits>&  operator<<(
                basic_ostream<_Elem,_Traits>& s
                ,
                const map<K,V>& m
            )
            {
                copy(m.begin(), m.end(), ostream_iterator<pair<K,V> >(s, "\n"));
                return s;
            }

            int main()
            {
                using namespace std;
                map<string,string> a;
                a["key1"]="value1";
                a["key2"]="value2";
                cout<<a;
                system("pause");
                return 0;
            }
            posted on 2007-05-09 13:10 張沈鵬 閱讀(1135) 評論(7)  編輯 收藏 引用 所屬分類: C++
            Comments
            • # re: C++ std名字空間ostream_iterator與的詭異問題
              金慶
              Posted @ 2007-10-13 12:31
              我不記得解答過你的這個問題...
              請不要直接顯示我的郵件地址,避免被用于垃圾郵件。  回復  更多評論   
            • # re: C++ std名字空間ostream_iterator與的詭異問題
              Minidx全文檢索
              Posted @ 2007-10-13 13:57
              居然還有這樣的事情……  回復  更多評論   
            • # re: C++ std名字空間ostream_iterator與的詭異問題
              張沈鵬
              Posted @ 2007-10-13 14:08
              fixed  回復  更多評論   
            • # That's not just the best aswner. It's the bestest answer!
              Fats
              Posted @ 2011-05-26 12:09
              That's not just the best aswner. It's the bestest answer!  回復  更多評論   
            • # More posts of this quality. Not the usual c***, pelase
              Liberty
              Posted @ 2011-05-26 13:28
              More posts of this quality. Not the usual c***, pelase  回復  更多評論   
             
            久久青青草原国产精品免费 | 亚洲欧洲中文日韩久久AV乱码| 亚洲国产精品婷婷久久| 国产日韩欧美久久| 欧美黑人激情性久久| 99久久人妻无码精品系列蜜桃| 99久久国产亚洲高清观看2024| 久久久久亚洲精品无码网址 | 久久av无码专区亚洲av桃花岛| 俺来也俺去啦久久综合网| 国产2021久久精品| 久久久噜噜噜久久中文福利| 久久99精品九九九久久婷婷| 久久99精品久久久大学生| 国产叼嘿久久精品久久| 亚洲精品无码久久久久久| 精品无码人妻久久久久久| 色婷婷综合久久久中文字幕| 青青青青久久精品国产h久久精品五福影院1421| 精品国产乱码久久久久久呢| 精品久久国产一区二区三区香蕉 | 亚洲乱码日产精品a级毛片久久| 久久久久亚洲av无码专区| 中文字幕无码久久人妻| 国产精品久久久久久久久久免费| 久久人人妻人人爽人人爽| 亚洲国产一成久久精品国产成人综合| 久久国产精品成人免费| 嫩草伊人久久精品少妇AV| 久久亚洲日韩看片无码| 久久婷婷五月综合成人D啪| 亚洲伊人久久大香线蕉苏妲己| 久久夜色精品国产噜噜麻豆| 97久久国产综合精品女不卡| 无码国内精品久久人妻麻豆按摩| 国产日韩久久久精品影院首页| 亚洲国产天堂久久综合网站| 国产成人精品久久亚洲高清不卡 | 99久久精品免费看国产免费| 国产亚洲精品自在久久| 久久久久久久综合日本亚洲|