iterator_range: Add an llvm::make_range() helper method.
authorJim Grosbach <grosbach@apple.com>
Thu, 10 Apr 2014 21:49:22 +0000 (21:49 +0000)
committerJim Grosbach <grosbach@apple.com>
Thu, 10 Apr 2014 21:49:22 +0000 (21:49 +0000)
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

include/llvm/ADT/iterator_range.h

index 4f2f3218f3104cfc4369e3db368fdfe0148f306f..6735700e046855dbbe5706b901dc345d8b46d7d7 100644 (file)
@@ -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