• <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 張沈鵬 閱讀(1142) 評論(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  回復  更多評論   
             
            国产精品一区二区久久精品涩爱| 91性高湖久久久久| 色播久久人人爽人人爽人人片AV| 久久无码AV一区二区三区| 久久永久免费人妻精品下载| 色综合久久久久| 精产国品久久一二三产区区别| 99精品国产99久久久久久97 | 91久久精品电影| 一极黄色视频久久网站| 亚洲中文字幕久久精品无码喷水| 久久se精品一区二区| 久久综合伊人77777麻豆| 久久精品无码午夜福利理论片| 久久久黄片| 久久精品国产99国产精偷| 香蕉久久夜色精品国产尤物| 久久精品中文字幕久久| 人人狠狠综合久久88成人| 久久伊人影视| 9999国产精品欧美久久久久久| 99精品国产综合久久久久五月天| 久久九九免费高清视频| 99久久免费国产精品| 成人国内精品久久久久影院| 久久国内免费视频| 四虎亚洲国产成人久久精品| 91亚洲国产成人久久精品| 91久久精品国产免费直播| 成人午夜精品久久久久久久小说 | 亚洲第一永久AV网站久久精品男人的天堂AV| 一本一道久久综合狠狠老| 亚洲欧美精品一区久久中文字幕| 国内精品久久久久久久涩爱 | 99久久国产主播综合精品| 欧洲成人午夜精品无码区久久 | 久久久久99精品成人片欧美| 久久久国产打桩机| 亚洲精品无码久久久影院相关影片| 国产精品亚洲综合久久| 久久精品国产免费观看|