[PATCH] D64997: [ADT] Add public iterator and cosnt_iterator types to iterator_range
Alex Brachet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 19 07:40:27 PDT 2019
abrachet created this revision.
abrachet added reviewers: jhenderson, rupprecht, MaskRay, Meinersbur.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.
iterator_range was originally modeled on a proposed std::iterator_range, I never found those papers but boost <https://github.com/boostorg/range/blob/develop/include/boost/range/iterator_range_core.hpp#L203>'s iterator_range publicly exposes these types.
https://reviews.llvm.org/D64997
Files:
llvm/include/llvm/ADT/iterator_range.h
Index: llvm/include/llvm/ADT/iterator_range.h
===================================================================
--- llvm/include/llvm/ADT/iterator_range.h
+++ llvm/include/llvm/ADT/iterator_range.h
@@ -29,7 +29,12 @@
/// fancy at all.
template <typename IteratorT>
class iterator_range {
- IteratorT begin_iterator, end_iterator;
+public:
+ using iterator = IteratorT;
+ using const_iterator = IteratorT;
+
+private:
+ iterator begin_iterator, end_iterator;
public:
//TODO: Add SFINAE to test that the Container's iterators match the range's
@@ -38,12 +43,12 @@
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)
+ iterator_range(iterator begin_iterator, iterator end_iterator)
: begin_iterator(std::move(begin_iterator)),
end_iterator(std::move(end_iterator)) {}
- IteratorT begin() const { return begin_iterator; }
- IteratorT end() const { return end_iterator; }
+ iterator begin() const { return begin_iterator; }
+ iterator end() const { return end_iterator; }
};
/// Convenience function for iterating over sub-ranges.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64997.210835.patch
Type: text/x-patch
Size: 1230 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190719/31a04ffb/attachment.bin>
More information about the llvm-commits
mailing list