• <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  回復  更多評論   
             
            日本精品久久久久影院日本 | 精品国产一区二区三区久久| 久久国产精品77777| 精品免费久久久久国产一区| 伊人久久大香线蕉av不卡| 99久久99这里只有免费费精品| 久久99精品免费一区二区| 精品国产99久久久久久麻豆| 伊人久久综在合线亚洲2019 | 无码国内精品久久综合88| 国内精品久久久人妻中文字幕| 久久久久这里只有精品 | 青青国产成人久久91网| 久久亚洲私人国产精品vA| 久久精品国产亚洲av麻豆蜜芽| 一级a性色生活片久久无| 人妻无码精品久久亚瑟影视| 久久99精品九九九久久婷婷| 精品免费tv久久久久久久| 欧美精品一本久久男人的天堂| 久久综合香蕉国产蜜臀AV| 一本久道久久综合狠狠爱| 国内精品久久久久久久97牛牛 | 亚洲精品久久久www| 国产精品无码久久综合| 国产毛片久久久久久国产毛片| 国产免费久久精品99久久| 蜜桃麻豆WWW久久囤产精品| 男女久久久国产一区二区三区| 国产三级精品久久| 久久人人爽人人爽人人片AV不| 91亚洲国产成人久久精品| 久久精品国产亚洲av麻豆图片| 欧美日韩中文字幕久久伊人| 亚洲va中文字幕无码久久| 精品久久久久久无码中文野结衣| 日韩精品久久久久久久电影蜜臀| 久久久久人妻一区精品果冻| 91精品国产综合久久久久久| 国产精品久久新婚兰兰 | 伊人色综合久久天天|