[PATCH] D114807: [llvm][stlextras] Add const methods to concat_range and enumerator
Jeff Niu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 30 09:37:13 PST 2021
Mogball created this revision.
Mogball added a reviewer: jpienaar.
Herald added a subscriber: dexonsmith.
Mogball requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D114807
Files:
llvm/include/llvm/ADT/STLExtras.h
Index: llvm/include/llvm/ADT/STLExtras.h
===================================================================
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -1019,17 +1019,31 @@
template <size_t... Ns> iterator begin_impl(std::index_sequence<Ns...>) {
return iterator(std::get<Ns>(Ranges)...);
}
+ template <size_t... Ns>
+ iterator begin_impl(std::index_sequence<Ns...>) const {
+ return iterator(std::get<Ns>(Ranges)...);
+ }
template <size_t... Ns> iterator end_impl(std::index_sequence<Ns...>) {
return iterator(make_range(std::end(std::get<Ns>(Ranges)),
std::end(std::get<Ns>(Ranges)))...);
}
+ template <size_t... Ns> iterator end_impl(std::index_sequence<Ns...>) const {
+ return iterator(make_range(std::end(std::get<Ns>(Ranges)),
+ std::end(std::get<Ns>(Ranges)))...);
+ }
public:
concat_range(RangeTs &&... Ranges)
: Ranges(std::forward<RangeTs>(Ranges)...) {}
iterator begin() { return begin_impl(std::index_sequence_for<RangeTs...>{}); }
+ iterator begin() const {
+ return begin_impl(std::index_sequence_for<RangeTs...>{});
+ }
iterator end() { return end_impl(std::index_sequence_for<RangeTs...>{}); }
+ iterator end() const {
+ return end_impl(std::index_sequence_for<RangeTs...>{});
+ }
};
} // end namespace detail
@@ -1977,10 +1991,16 @@
enumerator_iter<R> begin() {
return enumerator_iter<R>(0, std::begin(TheRange));
}
+ enumerator_iter<R> begin() const {
+ return enumerator_iter<R>(0, std::begin(TheRange));
+ }
enumerator_iter<R> end() {
return enumerator_iter<R>(std::end(TheRange));
}
+ enumerator_iter<R> end() const {
+ return enumerator_iter<R>(std::end(TheRange));
+ }
private:
R TheRange;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114807.390745.patch
Type: text/x-patch
Size: 1820 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211130/9040139f/attachment.bin>
More information about the llvm-commits
mailing list