summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2014-04-10 21:49:22 +0000
committerJim Grosbach <grosbach@apple.com>2014-04-10 21:49:22 +0000
commitb4dd10a72368943c4edff2562752f2e93ca8608f (patch)
treeb019113523636c93ef22583ec4c02e5eaeebdec2
parente7ef041ba4dceb57592e56369fef718a406ac2b5 (diff)
downloadllvm-b4dd10a72368943c4edff2562752f2e93ca8608f.tar.gz
llvm-b4dd10a72368943c4edff2562752f2e93ca8608f.tar.bz2
llvm-b4dd10a72368943c4edff2562752f2e93ca8608f.tar.xz
iterator_range: Add an llvm::make_range() helper method.
Convenience wrapper to make dealing with sub-ranges easier. Like the iterator_range<> itself, if/when this sort of thing gets standards blessing, it will be replaced by the official version. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205987 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/iterator_range.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/llvm/ADT/iterator_range.h b/include/llvm/ADT/iterator_range.h
index 4f2f3218f3..6735700e04 100644
--- a/include/llvm/ADT/iterator_range.h
+++ b/include/llvm/ADT/iterator_range.h
@@ -40,6 +40,14 @@ public:
IteratorT begin() const { return begin_iterator; }
IteratorT end() const { return end_iterator; }
};
+
+/// \brief Convenience function for iterating over sub-ranges.
+///
+/// This provides a bit of syntactic sugar to make using sub-ranges
+/// in for loops a bit easier. Analogous to std::make_pair().
+template<class T> iterator_range<T> make_range(const T &x, const T &y) {
+ return (iterator_range<T>(x, y));
+}
}
#endif