From b4dd10a72368943c4edff2562752f2e93ca8608f Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Thu, 10 Apr 2014 21:49:22 +0000 Subject: [PATCH] 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 --- include/llvm/ADT/iterator_range.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/llvm/ADT/iterator_range.h b/include/llvm/ADT/iterator_range.h index 4f2f3218f31..6735700e046 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 iterator_range make_range(const T &x, const T &y) { + return (iterator_range(x, y)); +} } #endif