diff --git a/include/oneapi/dpl/pstl/zip_view_impl.h b/include/oneapi/dpl/pstl/zip_view_impl.h index 913724ee0c..6b3afad9e0 100644 --- a/include/oneapi/dpl/pstl/zip_view_impl.h +++ b/include/oneapi/dpl/pstl/zip_view_impl.h @@ -293,22 +293,25 @@ class zip_view : public std::ranges::view_interface> { tuple_type...>>; end_type end_; - }; // class sentinel + }; // class sentinel -private: - template - constexpr auto begin_impl() + constexpr auto begin() requires (std::ranges::range && ...) // !simple_view? { - auto __tr = [](auto... __args) { return iterator(__args...);}; + auto __tr = [](auto... __args) { return iterator(__args...);}; return apply_to_tuple(__tr, std::ranges::begin, views_); } - template - constexpr auto end_impl() + constexpr auto begin() const requires ( std::ranges::range && ... ) + { + auto __tr = [](auto... __args) { return iterator(__args...);}; + return apply_to_tuple(__tr, std::ranges::begin, views_); + } + + constexpr auto end() requires (std::ranges::range && ...) // requires !simple_view { { if constexpr (!zip_is_common) { - auto __tr = [](auto... __args) { return sentinel(__args...);}; + auto __tr = [](auto... __args) { return sentinel(__args...);}; return apply_to_tuple(__tr, std::ranges::end, views_); } else if constexpr ((std::ranges::random_access_range && ...)) @@ -319,30 +322,29 @@ class zip_view : public std::ranges::view_interface> { } else { - auto __tr = [](auto... __args) { return iterator(__args...);}; + auto __tr = [](auto... __args) { return iterator(__args...);}; return apply_to_tuple(__tr, std::ranges::end, views_); } } -public: - constexpr auto begin() requires (std::ranges::range && ...) // !simple_view? - { - return begin_impl(); - } - - constexpr auto begin() const requires ( std::ranges::range && ... ) - { - return const_cast(this)->begin_impl(); - } - - constexpr auto end() requires (std::ranges::range && ...) // requires !simple_view { - { - return end_impl(); - } - constexpr auto end() const requires (std::ranges::range && ...) { - return const_cast(this)->end_impl(); + if constexpr (!zip_is_common) + { + auto __tr = [](auto... __args) { return sentinel(__args...);}; + return apply_to_tuple(__tr, std::ranges::end, views_); + } + else if constexpr ((std::ranges::random_access_range && ...)) + { + auto it = begin(); + it += size(); + return it; + } + else + { + auto __tr = [](auto... __args) { return iterator(__args...);}; + return apply_to_tuple(__tr, std::ranges::end, views_); + } } constexpr auto size() requires (std::ranges::sized_range && ...)