Skip to content
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

Cleanups: Friendship is magic #3524

Merged

Conversation

StephanTLavavej
Copy link
Member

  • When granting friendship to bitset, use its injected-class-name.
  • In <ranges>, consistently grant access to the parent meow_view. This avoids needing forward declarations.
    • join_view is being updated by Implement P2770R0 "Stashing stashing iterators for proper flattening" #3466, so I'm not changing it here.
    • This takes advantage of a C++ rule: nested classes are members of their parent class, so they have the same access rights as any other member. This means that if Nested1 grants friendship to its Parent, then Nested2 can now access Nested1's internals.
    • Several other views/iterators are already using this scheme, so this increases consistency. It does widen the scope of friendship, but that doesn't really matter - a view and its iterators/sentinels are tightly coupled, so it's okay for the different parts to have access to one another.
  • Drop unnecessary forward declaration of _Locimp.
    • This is an unrelated micro-cleanup, grouped here because I want to make an edit in the same area:
  • Use forward declarations and extended friends instead of elaborated-type-specifiers.
    • We consider it confusing that friend struct Meow; can declare Meow. The rules for this are complicated and we'd prefer not to have to think so hard. It's easier if we have separate forward declarations, followed by the "extended friend" syntax. Although this consumes an extra line, it's simpler because friend Meow; is incapable of introducing a declaration.

@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Mar 3, 2023
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner March 3, 2023 19:31
@StephanTLavavej StephanTLavavej added the ranges C++20/23 ranges label Mar 3, 2023
@StephanTLavavej StephanTLavavej self-assigned this Mar 7, 2023
@StephanTLavavej
Copy link
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 1435752 into microsoft:main Mar 7, 2023
@StephanTLavavej StephanTLavavej deleted the stl-cleanups-friendship branch March 7, 2023 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved ranges C++20/23 ranges
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants