-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid "friends of friends" (CWG1699) in common_iterator
#2066
Conversation
CWG consensus is that friend functions defined inline in a class `X` should be treated as friends of classes that befriend `X`, but there's implementation divergence. (Probably because the issue has been in "drafting" for eight years.) Fixes microsoft#2065
template <input_or_output_iterator _OIter, sentinel_for<_OIter> _OSe> | ||
requires (!same_as<_OIter, _OSe> && copyable<_OIter>) | ||
friend class common_iterator; | ||
// clang-format on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the removal of cross-specialization friendship here; I've chosen to use _Get_val
consistently in both member functions and friend functions.
LGTM except that I am missing some test coverage |
Something funny is going on: we are somehow missing cross-type comparison coverage, but we do have cross-type difference coverage which is not failing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I'll validate and push simple changes.
This comment has been minimized.
This comment has been minimized.
I'm mirroring this to an MSVC-internal PR. Please notify me if any further changes are pushed. |
Thanks for fixing this friendship bug! 😸 🎉 🚀 |
CWG consensus is that friend functions defined inline in a class
X
should be treated as friends of classes that befriendX
, but there's implementation divergence. (Probably because the issue has been in "drafting" for eight years.)Fixes #2065