From: David Blaikie Date: Tue, 21 Jul 2015 18:37:12 +0000 (+0000) Subject: Add some utilities to iterator_range for trimming a range and constructing one from... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2f6af0e27750a48871ff6e796206d5b71f204868;p=oota-llvm.git Add some utilities to iterator_range for trimming a range and constructing one from a container. To be used in clang in a follow-up commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242823 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/iterator_range.h b/include/llvm/ADT/iterator_range.h index 523a86f02e0..3dd679bd9b7 100644 --- a/include/llvm/ADT/iterator_range.h +++ b/include/llvm/ADT/iterator_range.h @@ -20,6 +20,7 @@ #define LLVM_ADT_ITERATOR_RANGE_H #include +#include namespace llvm { @@ -32,6 +33,12 @@ class iterator_range { IteratorT begin_iterator, end_iterator; public: + //TODO: Add SFINAE to test that the Container's iterators match the range's + // iterators. + template + iterator_range(Container &&c) + //TODO: Consider ADL/non-member begin/end calls. + : begin_iterator(c.begin()), end_iterator(c.end()) {} iterator_range(IteratorT begin_iterator, IteratorT end_iterator) : begin_iterator(std::move(begin_iterator)), end_iterator(std::move(end_iterator)) {} @@ -51,6 +58,11 @@ template iterator_range make_range(T x, T y) { template iterator_range make_range(std::pair p) { return iterator_range(std::move(p.first), std::move(p.second)); } + +template +iterator_range()))> drop_begin(T &&t, int n) { + return make_range(std::next(begin(t), n), end(t)); +} } #endif