-
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
My Little Operator: Friendship Is Magic #2797
My Little Operator: Friendship Is Magic #2797
Conversation
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.
That is soo much better
I'm speculatively mirroring this to the MSVC-internal repo. Further changes can be pushed, but please notify me. |
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.
Ugh, <iomanip>
was a mess to review.
Thanks for slogging through it - |
Stephan, |
@DanielaE Thanks for the heads up! 😸 |
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:
export
ed. (Namespace-scope operators would have to be individuallyexport
ed.)A few notes:
span::iterator
has 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._Elem
and_Elem2
template parameters have to "trade places" when becoming hidden friends. Westatic_assert
that 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_out
before_Quote_in
._Quote_out
.", I had to rename to_OsTraits
to avoid a collision, and useclass _QuTraits = _Traits
both 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.🐴 🪄 🦄