My Little Operator: Friendship Is Magic#2797
Merged
StephanTLavavej merged 11 commits intoJun 20, 2022
Merged
Conversation
Member
Author
|
I'm speculatively mirroring this to the MSVC-internal repo. Further changes can be pushed, but please notify me. |
CaseyCarter
approved these changes
Jun 19, 2022
Contributor
CaseyCarter
left a comment
There was a problem hiding this comment.
Ugh, <iomanip> was a mess to review.
Member
Author
Thanks for slogging through it - |
|
Stephan, |
Member
Author
|
@DanielaE Thanks for the heads up! 😸 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changes all of the STL's operators that are required to exist, but that aren't required to be namespace-scope functions, into "hidden friends". (For example,
n + vector::iterator.)Hidden friends are great in two different ways:
exported. (Namespace-scope operators would have to be individuallyexported.)A few notes:
span::iteratorhas used hidden friends since <span>: fix cross-type iterator operations #474 and currently says:STL/stl/inc/span
Line 117 in ea32e86
<iomanip>diff looks horrible, but I've structured it into a series of commits for easier reviewing._Elemand_Elem2template parameters have to "trade places" when becoming hidden friends. Westatic_assertthat they're the same, so there is no potential for mistakes.quoted()needed extra attention due to how its operators referred to each other. I recommend diffing the "before" and "after" parts of each commit._Quote_outbefore_Quote_in._Quote_out.", I had to rename to_OsTraitsto avoid a collision, and useclass _QuTraits = _Traitsboth for clarity and to delay evaluation ofis_void_v<_QuTraits>._Quote_in, part 1.", instead of callingquoted(), I directly construct a_Quote_out(thanks to the earlier code movement)._Quote_in, part 2." is nearly pure code movement.🐴 🪄 🦄