[llvm] 7512a92 - [llvm][stlextras] Add const methods to concat_range and enumerator
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 1 08:52:51 PST 2021
Author: Mogball
Date: 2021-12-01T16:52:46Z
New Revision: 7512a9280a41b9810f1bd0d8e08200abbc8de5da
URL: https://github.com/llvm/llvm-project/commit/7512a9280a41b9810f1bd0d8e08200abbc8de5da
DIFF: https://github.com/llvm/llvm-project/commit/7512a9280a41b9810f1bd0d8e08200abbc8de5da.diff
LOG: [llvm][stlextras] Add const methods to concat_range and enumerator
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D114807
Added:
Modified:
llvm/include/llvm/ADT/STLExtras.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 48f15b02283a6..f9b658ca960a6 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1016,20 +1016,39 @@ template <typename ValueT, typename... RangeTs> class concat_range {
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 @@ template <typename R> class enumerator {
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;
More information about the llvm-commits
mailing list