zip_view: make equality operator member function, not hidden friend#2624
zip_view: make equality operator member function, not hidden friend#2624danhoeflinger wants to merge 8 commits intomainfrom
Conversation
There was a problem hiding this comment.
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–sentineloperator==from a hidden friend to a member function. - Remove the
_MSC_VER-gatedpublic:workaround that previously exposedsentinel::__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, butiteratorstill declares a hidden-friendoperator-(const iterator&, const sentinel&)that calls__y.__get_end(). That free function won’t inheritzip_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 asoperator==: make the iterator–sentineloperator-aiteratormember (or otherwise grant it access via an explicit friend declaration) so it can legally callsentinel::__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.
There was a problem hiding this comment.
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–sentineloperator==from a hidden friend to aconstmember function. - Remove the MSVC-specific workaround that temporarily exposed
sentinel::__get_end()aspublic.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
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 == sentinelfrom a hidden friend to an iterator memberoperator==. - Convert
zip_view::iterator - sentinelfrom a hidden friend to an iterator memberoperator-, keepingsentinel - iteratoras 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.
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>
daa8b16 to
65bc50f
Compare
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
|
@MikeDvorskiy @kboyarinov I do still think this is the better version of our previous workaround, and is worth considering. |
|
@MikeDvorskiy What do you think of this? |
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 foroperator-and coverage changes is still pending.