Created
April 8, 2010 03:52
-
-
Save viksit/359756 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <map> | |
using namespace std; | |
template <typename K, typename V, class C, class A> | |
ostream &operator<< (ostream &os, map<K,V,C,A> const& m) | |
{ | |
os << "{ "; | |
typename map<K,V,C,A>::const_iterator p; | |
for (p = m.begin(); p != m.end(); ++p) { | |
os << p->first << ":" << p->second << ", "; | |
} | |
return os << "}"; | |
} | |
int main (int argc, char *argv[]) | |
{ | |
typedef map<int, string> Map1; | |
typedef map<double, Map1> Map2; | |
Map2 m; | |
m.insert (make_pair (1.2, Map1 ())); | |
m[1.2].insert (make_pair (3, "three")); | |
m[1.2].insert (make_pair (5, "five")); | |
m.insert (make_pair (.5, Map1 ())); | |
m[.5].insert (make_pair (5, "five")); | |
m[.5].insert (make_pair (1, "one")); | |
m[.5].insert (make_pair (9, "nine")); | |
cout << m << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment