Skip to content

Instantly share code, notes, and snippets.

@taksatou
Created May 28, 2011 12:51
Show Gist options
  • Save taksatou/996840 to your computer and use it in GitHub Desktop.
Save taksatou/996840 to your computer and use it in GitHub Desktop.
#include <memory>
using namespace std;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U> p) {
os << '(' << p.first << ',' << p.second << ')';
return os;
}
template <typename T,
template <typename _1, typename _2=allocator<_1> > class Container>
ostream& operator<<(ostream& os, const Container<T>& p) {
typename Container<T>::const_iterator e = p.end();
for (typename Container<T>::const_iterator it = p.begin(); it != e; ++it)
os << *it << '\n';
return os;
}
template <typename T,
template <typename _1, typename _2, typename _3=allocator<_1> > class Container,
template <typename> class Compare>
ostream& operator<<(ostream& os, const Container<T, Compare<T> >& p) {
typename Container<T, Compare<T> >::const_iterator e = p.end();
for (typename Container<T, Compare<T> >::const_iterator it = p.begin(); it != e; ++it)
os << *it << '\n';
return os;
}
template <typename T, typename U,
template <typename _1, typename _2, typename _3, typename _4=allocator<pair<const _1, _2> > > class Container,
template <typename> class Compare>
ostream& operator<<(ostream& os, const Container<T, U, Compare<T> >& p) {
typename Container<T, U, Compare<T> >::const_iterator e = p.end();
for (typename Container<T, U, Compare<T> >::const_iterator it = p.begin(); it != e; ++it)
os << *it << '\n';
return os;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment