[llvm] r205987 - iterator_range: Add an llvm::make_range() helper method.

Jim Grosbach grosbach at apple.com
Thu Apr 10 14:49:22 PDT 2014


Author: grosbach
Date: Thu Apr 10 16:49:22 2014
New Revision: 205987

URL: http://llvm.org/viewvc/llvm-project?rev=205987&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/ADT/iterator_range.h

Modified: llvm/trunk/include/llvm/ADT/iterator_range.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/iterator_range.h?rev=205987&r1=205986&r2=205987&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/iterator_range.h (original)
+++ llvm/trunk/include/llvm/ADT/iterator_range.h Thu Apr 10 16:49:22 2014
@@ -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





More information about the llvm-commits mailing list