summaryrefslogtreecommitdiff
path: root/src/common.hpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2015-09-01 14:51:21 +0800
committerJohn Hodge <tpg@mutabah.net>2015-09-01 14:51:21 +0800
commitdb10e8219fefb01415b3a79e973844401d97c1ee (patch)
treeb154916bd7dcb4fc7beb9903a195d4a0b0900765 /src/common.hpp
parent68607811e4e8d6feba95f55c3e49da9923fc35fd (diff)
downloadmrust-db10e8219fefb01415b3a79e973844401d97c1ee.tar.gz
Large rework to generic bounds (to use a tagged union)
Diffstat (limited to 'src/common.hpp')
-rw-r--r--src/common.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common.hpp b/src/common.hpp
index 8fef294a..753d06a6 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -95,6 +95,24 @@ struct LList
};
};
+template<typename T>
+struct Join {
+ const char *sep;
+ const ::std::vector<T>& v;
+ friend ::std::ostream& operator<<(::std::ostream& os, const Join& j) {
+ if( j.v.size() > 0 )
+ os << j.v[0];
+ for( unsigned int i = 1; i < j.v.size(); i ++ )
+ os << j.sep << j.v[i];
+ return os;
+ }
+};
+template<typename T>
+inline Join<T> join(const char *sep, const ::std::vector<T> v) {
+ return Join<T>({ sep, v });
+}
+
+
namespace std {
template <typename T>
@@ -113,6 +131,7 @@ 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::vector<T>& v) {
if( v.size() > 0 )