[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
Wed Dec 1 08:52:55 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7512a9280a41: [llvm][stlextras] Add const methods to concat_range and enumerator (authored by Mogball).
Changed prior to commit:
https://reviews.llvm.org/D114807?vs=390745&id=391050#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114807/new/
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
@@ -1016,20 +1016,39 @@
private:
std::tuple<RangeTs...> Ranges;
- template <size_t... Ns> iterator begin_impl(std::index_sequence<Ns...>) {
+ 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 end() { return end_impl(std::index_sequence_for<RangeTs...>{}); }
+ 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 +1996,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.391050.patch
Type: text/x-patch
Size: 2122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211201/bab5d44c/attachment.bin>
More information about the llvm-commits
mailing list