diff --git a/include/oneapi/dpl/pstl/utils_ranges.h b/include/oneapi/dpl/pstl/utils_ranges.h index 0b6faf72492..462886ce48b 100644 --- a/include/oneapi/dpl/pstl/utils_ranges.h +++ b/include/oneapi/dpl/pstl/utils_ranges.h @@ -360,6 +360,18 @@ class zip_view explicit zip_view(_Ranges... __args) : __m_ranges(__args...) {} + auto + begin() const + { + return __make_begin(std::make_index_sequence<__num_ranges>()); + } + + auto + end() const + { + return __make_end(std::make_index_sequence<__num_ranges>()); + } + auto size() const { @@ -387,6 +399,20 @@ class zip_view } private: + template + auto + __make_begin(std::index_sequence<_Ip...>) const + { + return oneapi::dpl::make_zip_iterator(oneapi::dpl::__ranges::__begin(std::get<_Ip>(__m_ranges))...); + } + + template + auto + __make_end(std::index_sequence<_Ip...>) const + { + return oneapi::dpl::make_zip_iterator(oneapi::dpl::__ranges::__end(std::get<_Ip>(__m_ranges))...); + } + _tuple_ranges_t __m_ranges; }; @@ -454,6 +480,18 @@ struct reverse_view_simple reverse_view_simple(_R __rng) : __r(__rng) {} + auto + begin() const + { + return std::make_reverse_iterator(__begin(__r) + size()); + } + + auto + end() const + { + return std::make_reverse_iterator(__begin(__r)); + } + //TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range template auto operator[](Idx __i) const -> decltype(__r[__i]) @@ -495,6 +533,18 @@ struct take_view_simple assert(__n >= 0 && __n <= oneapi::dpl::__ranges::__size(__r)); } + auto + begin() const + { + return __begin(__r); + } + + auto + end() const + { + return __begin(__r) + __n; + } + //TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range template auto operator[](Idx __i) const -> decltype(__r[__i]) @@ -591,6 +641,21 @@ struct replicate_start_view_simple assert(__repl_count >= 0); } + auto + begin() const + { + auto __map_fn = [__c = __repl_count](auto __i) -> decltype(__i) { + return __i < __c ? decltype(__i)(0) : __i - __c; + }; + return oneapi::dpl::make_permutation_iterator(__begin(__r), __map_fn); + } + + auto + end() const + { + return begin() + size(); + } + //TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range template auto operator[](Idx __i) const -> decltype(__r[__i]) @@ -627,6 +692,18 @@ struct transform_view_simple _R __r; _F __f; + auto + begin() const + { + return oneapi::dpl::make_transform_iterator(__begin(__r), __f); + } + + auto + end() const + { + return begin() + size(); + } + //TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range template auto operator[](Idx __i) const -> decltype(__f(__r[__i])) @@ -685,6 +762,21 @@ struct permutation_view_simple<_Source, _M, ::std::enable_if_t) + return oneapi::dpl::make_permutation_iterator(__src, __map_fn); + else + return oneapi::dpl::make_permutation_iterator(__begin(__src), __map_fn); + } + + auto + end() const + { + return begin() + __size; + } + //TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range template decltype(auto) @@ -724,6 +816,21 @@ struct permutation_view_simple<_Source, _M, ::std::enable_if_t:: permutation_view_simple(_Source __data, _M __m) : __src(__data), __map(__m) {} + auto + begin() const + { + if constexpr (oneapi::dpl::__internal::__is_random_access_iterator_v<_Source>) + return oneapi::dpl::make_permutation_iterator(__src, __begin(__map)); + else + return oneapi::dpl::make_permutation_iterator(__begin(__src), __begin(__map)); + } + + auto + end() const + { + return begin() + size(); + } + //TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range template decltype(auto)