Skip to content

zip_view: make equality operator member function, not hidden friend#2624

Open
danhoeflinger wants to merge 8 commits intomainfrom
dev/dhoeflin/zip_view_friend_fix
Open

zip_view: make equality operator member function, not hidden friend#2624
danhoeflinger wants to merge 8 commits intomainfrom
dev/dhoeflin/zip_view_friend_fix

Conversation

@danhoeflinger
Copy link
Copy Markdown
Contributor

@danhoeflinger danhoeflinger commented Mar 17, 2026

Convert the zip_view iterator-sentinel operator== from a hidden friend to a member function to fix a compilation error on GCC. As a hidden friend, the operator lacked access to sentinel's private __get_end() method because friend functions don't inherit the access rights of their enclosing class. Making it a member function resolves this portably, as member functions of a nested class inherit the enclosing class's friendships. This also removes the existing MSVC workaround that made __get_end() public on that compiler for the same reason.

Pending CI test run.

Update: CI run looks good for the operator== changes. It may be good to think about this a little more though, and CI for operator- and coverage changes is still pending.

@danhoeflinger danhoeflinger changed the title make equality operator member function, not hidden friend zip_view: make equality operator member function, not hidden friend Mar 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates zip_view’s iterator/sentinel comparison implementation to fix a GCC compilation error by moving the iterator–sentinel operator== from a hidden friend to an iterator member function, and removes the prior MSVC-only access workaround on the sentinel.

Changes:

  • Convert zip_view::iterator’s iterator–sentinel operator== from a hidden friend to a member function.
  • Remove the _MSC_VER-gated public: workaround that previously exposed sentinel::__get_end().
Comments suppressed due to low confidence (1)

include/oneapi/dpl/pstl/zip_view_impl.h:433

  • sentinel::__get_end() is now unconditionally private, but iterator still declares a hidden-friend operator-(const iterator&, const sentinel&) that calls __y.__get_end(). That free function won’t inherit zip_view’s friendship, so this will still be a hard compile error (and will be instantiated by the existing zip_view.minus tests). Consider applying the same fix as operator==: make the iterator–sentinel operator- a iterator member (or otherwise grant it access via an explicit friend declaration) so it can legally call sentinel::__get_end().
        friend class zip_view;

        decltype(auto)
        __get_end() const
        {
            return __end;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Base automatically changed from dev/dhoeflin/zip_view_sycl_device_copyable to dev/mdvorski/zip_view March 17, 2026 15:36
@danhoeflinger danhoeflinger requested a review from Copilot March 17, 2026 15:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts zip_view’s iterator–sentinel equality to be a member function (instead of a hidden friend) to ensure it can access the sentinel’s private __get_end() and compile correctly on GCC.

Changes:

  • Convert zip_view::iterator’s iterator–sentinel operator== from a hidden friend to a const member function.
  • Remove the MSVC-specific workaround that temporarily exposed sentinel::__get_end() as public.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/oneapi/dpl/pstl/zip_view_impl.h
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates zip_view’s iterator/sentinel comparisons to avoid a GCC access-control compilation issue by moving operator== (and iterator - sentinel) from hidden friends to iterator member functions, leveraging the enclosing class friendship to access sentinel::__get_end(). It also adds targeted tests to exercise iterator/sentinel equality and subtraction in non-common-range scenarios.

Changes:

  • Convert zip_view::iterator == sentinel from a hidden friend to an iterator member operator==.
  • Convert zip_view::iterator - sentinel from a hidden friend to an iterator member operator-, keeping sentinel - iterator as a delegating hidden friend.
  • Add regression tests covering iterator/sentinel ==, !=, and - with unbounded and forward-only + sized-sentinel ranges.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
include/oneapi/dpl/pstl/zip_view_impl.h Moves iterator/sentinel operator== and operator- to iterator members and removes the MSVC-only public __get_end() workaround.
test/parallel_api/ranges/zip_view.pass.cpp Adds new C++20 ranges tests to validate iterator/sentinel equality and sized-sentinel subtraction behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/parallel_api/ranges/zip_view.pass.cpp Outdated
Base automatically changed from dev/mdvorski/zip_view to main March 17, 2026 21:04
danhoeflinger and others added 6 commits March 18, 2026 09:00
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---------

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Co-authored-by: Mikhail Dvorskiy <mikhail.dvorskiy@intel.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Dan Hoeflinger
<dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@danhoeflinger danhoeflinger force-pushed the dev/dhoeflin/zip_view_friend_fix branch from daa8b16 to 65bc50f Compare March 18, 2026 13:01
danhoeflinger and others added 2 commits March 20, 2026 12:14
@danhoeflinger
Copy link
Copy Markdown
Contributor Author

@MikeDvorskiy @kboyarinov I do still think this is the better version of our previous workaround, and is worth considering.

Copy link
Copy Markdown
Contributor

@kboyarinov kboyarinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@danhoeflinger
Copy link
Copy Markdown
Contributor Author

@MikeDvorskiy What do you think of this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants