Skip to content

Cleanups: Friendship is magic - #3524

Merged
Stephan T. Lavavej (StephanTLavavej) merged 4 commits into
microsoft:mainfrom
StephanTLavavej:stl-cleanups-friendship
Mar 7, 2023
Merged

Cleanups: Friendship is magic#3524
Stephan T. Lavavej (StephanTLavavej) merged 4 commits into
microsoft:mainfrom
StephanTLavavej:stl-cleanups-friendship

Conversation

@StephanTLavavej

Copy link
Copy Markdown
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

Copy link
Copy Markdown
Member Author

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

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 1435752 into microsoft:main Mar 7, 2023
@StephanTLavavej
Stephan T. Lavavej (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