diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-26 12:47:56 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-26 12:47:56 +0800 |
commit | 942f7025ce5c1e24330d001cd350c4fc0712a560 (patch) | |
tree | f0132f3c0feb7a7097da4d3d7412ce26f0bf7873 | |
parent | 84a25f125148ec6b23bc679407c838bcf7ea5da9 (diff) | |
download | mrust-942f7025ce5c1e24330d001cd350c4fc0712a560.tar.gz |
common - Add print for std::set
-rw-r--r-- | src/common.hpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common.hpp b/src/common.hpp index 35113670..e58fc0da 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -6,6 +6,7 @@ #include <iostream> #include <vector> #include <map> +#include <set> #include <cassert> #include <sstream> #include <memory> @@ -223,6 +224,21 @@ inline ::std::ostream& operator<<(::std::ostream& os, const ::std::vector<T>& v) } return os; } +template <typename T> +inline ::std::ostream& operator<<(::std::ostream& os, const ::std::set<T>& v) { + if( v.size() > 0 ) + { + bool is_first = true; + for( const auto& i : v ) + { + if(!is_first) + os << ", "; + is_first = false; + os << i; + } + } + return os; +} template <typename T, typename U> inline ::std::ostream& operator<<(::std::ostream& os, const ::std::pair<T,U>& v) { |