вывод вложенных map/vector

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
template<class K, class V>
ostream & operator<<(ostream &o, const map<K,V>& m) {
o << "<map>";
typename map<K, V>::const_iterator it;
for(it=m.begin();it!=m.end();it++)
{
o << "{" << (*it).first << ";";
o << (*it).second << "};";
}
o << "</map>";
return o;
}
template<class T>
ostream& operator<<(ostream &o, const vector<T>& v) {
o << "<vector>";
typename vector<T>::const_iterator it;
for (it=v.begin(); it!=v.end(); it++) {
o << *it << ";";
}
o << "</vector>";
}