diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -1019,17 +1019,31 @@ template iterator begin_impl(std::index_sequence) { return iterator(std::get(Ranges)...); } + template + iterator begin_impl(std::index_sequence) const { + return iterator(std::get(Ranges)...); + } template iterator end_impl(std::index_sequence) { return iterator(make_range(std::end(std::get(Ranges)), std::end(std::get(Ranges)))...); } + template iterator end_impl(std::index_sequence) const { + return iterator(make_range(std::end(std::get(Ranges)), + std::end(std::get(Ranges)))...); + } public: concat_range(RangeTs &&... Ranges) : Ranges(std::forward(Ranges)...) {} iterator begin() { return begin_impl(std::index_sequence_for{}); } + iterator begin() const { + return begin_impl(std::index_sequence_for{}); + } iterator end() { return end_impl(std::index_sequence_for{}); } + iterator end() const { + return end_impl(std::index_sequence_for{}); + } }; } // end namespace detail @@ -1977,10 +1991,16 @@ enumerator_iter begin() { return enumerator_iter(0, std::begin(TheRange)); } + enumerator_iter begin() const { + return enumerator_iter(0, std::begin(TheRange)); + } enumerator_iter end() { return enumerator_iter(std::end(TheRange)); } + enumerator_iter end() const { + return enumerator_iter(std::end(TheRange)); + } private: R TheRange;