summaryrefslogtreecommitdiff
path: root/src/common.hpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-06-06 17:25:17 +0800
committerJohn Hodge <tpg@mutabah.net>2016-06-06 17:25:17 +0800
commitbfec0115e412b584822d78b71f8fc9e30467d5dc (patch)
tree8aa0fb102208aee1423761649628e0f6ca43d9be /src/common.hpp
parent0821649dd024ae715769daa30d1d85fdd13e576b (diff)
downloadmrust-bfec0115e412b584822d78b71f8fc9e30467d5dc.tar.gz
HIR - Maintain trait list, use it for method lookup
Diffstat (limited to 'src/common.hpp')
-rw-r--r--src/common.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common.hpp b/src/common.hpp
index da2c3898..bb3ef72e 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -208,4 +208,18 @@ inline ::std::ostream& operator<<(::std::ostream& os, const ::std::multimap<T,U,
}
+// -------------------------------------------------------------------
+// --- Reversed iterable
+template <typename T>
+struct reversion_wrapper { T& iterable; };
+
+template <typename T>
+auto begin (reversion_wrapper<T> w) { return ::std::rbegin(w.iterable); }
+
+template <typename T>
+auto end (reversion_wrapper<T> w) { return ::std::rend(w.iterable); }
+
+template <typename T>
+reversion_wrapper<T> reverse (T&& iterable) { return { iterable }; }
+
#endif