Skip to content

Commit

Permalink
Revert "[oneDPL][ranges][zip_view] + begin_imp, end_impl to reduce co…
Browse files Browse the repository at this point in the history
…de duplication"

This reverts commit fc04caf.
  • Loading branch information
MikeDvorskiy committed Sep 26, 2024
1 parent fc04caf commit 91cf6b0
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions include/oneapi/dpl/pstl/zip_view_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,22 +293,25 @@ class zip_view : public std::ranges::view_interface<zip_view<Views...>> {
tuple_type<std::ranges::sentinel_t<const Views>...>>;

end_type end_;
}; // class sentinel
}; // class sentinel

private:
template<bool Const>
constexpr auto begin_impl()
constexpr auto begin() requires (std::ranges::range<Views> && ...) // !simple_view?
{
auto __tr = [](auto... __args) { return iterator<Const>(__args...);};
auto __tr = [](auto... __args) { return iterator<false>(__args...);};
return apply_to_tuple(__tr, std::ranges::begin, views_);
}

template<bool Const>
constexpr auto end_impl()
constexpr auto begin() const requires ( std::ranges::range<const Views> && ... )
{
auto __tr = [](auto... __args) { return iterator<true>(__args...);};
return apply_to_tuple(__tr, std::ranges::begin, views_);
}

constexpr auto end() requires (std::ranges::range<Views> && ...) // requires !simple_view {
{
if constexpr (!zip_is_common<Views...>)
{
auto __tr = [](auto... __args) { return sentinel<Const>(__args...);};
auto __tr = [](auto... __args) { return sentinel<false>(__args...);};
return apply_to_tuple(__tr, std::ranges::end, views_);
}
else if constexpr ((std::ranges::random_access_range<Views> && ...))
Expand All @@ -319,30 +322,29 @@ class zip_view : public std::ranges::view_interface<zip_view<Views...>> {
}
else
{
auto __tr = [](auto... __args) { return iterator<Const>(__args...);};
auto __tr = [](auto... __args) { return iterator<false>(__args...);};
return apply_to_tuple(__tr, std::ranges::end, views_);
}
}

public:
constexpr auto begin() requires (std::ranges::range<Views> && ...) // !simple_view?
{
return begin_impl<false>();
}

constexpr auto begin() const requires ( std::ranges::range<const Views> && ... )
{
return const_cast<zip_view*>(this)->begin_impl<true>();
}

constexpr auto end() requires (std::ranges::range<Views> && ...) // requires !simple_view {
{
return end_impl<false>();
}

constexpr auto end() const requires (std::ranges::range<const Views> && ...)
{
return const_cast<zip_view*>(this)->end_impl<true>();
if constexpr (!zip_is_common<Views...>)
{
auto __tr = [](auto... __args) { return sentinel<true>(__args...);};
return apply_to_tuple(__tr, std::ranges::end, views_);
}
else if constexpr ((std::ranges::random_access_range<Views> && ...))
{
auto it = begin();
it += size();
return it;
}
else
{
auto __tr = [](auto... __args) { return iterator<true>(__args...);};
return apply_to_tuple(__tr, std::ranges::end, views_);
}
}

constexpr auto size() requires (std::ranges::sized_range<Views> && ...)
Expand Down

0 comments on commit 91cf6b0

Please sign in to comment.