This is an archive of the discontinued LLVM Phabricator instance.

[libcxx][nfc] makes comparison operators for `std::*_ordering` types hidden friends
ClosedPublic

Authored by cjdb on May 1 2021, 9:02 PM.

Details

Summary

The standard leaves it up to the implementation to decide whether or not
these operators are hidden friends. There are several (well-documented)
reasons to prefer hidden friends, as well as an argument for improved
readability.

Depends on D100342.

Diff Detail

Event Timeline

cjdb requested review of this revision.May 1 2021, 9:02 PM
cjdb created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 1 2021, 9:02 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
cjdb updated this revision to Diff 344114.May 10 2021, 10:34 AM

rebases to activate CI

zoecarver accepted this revision as: zoecarver.May 10 2021, 4:01 PM
zoecarver added a subscriber: zoecarver.

Can you update the title/commit to say this is a NFC.

Then, get another approval and ship it!!

cjdb updated this revision to Diff 344229.May 10 2021, 4:07 PM
cjdb retitled this revision from [libcxx] makes comparison operators for `std::*_ordering` types hidden friends to [libcxx][nfc] makes comparison operators for `std::*_ordering` types hidden friends.

updates commit message

Quuxplusone accepted this revision.May 10 2021, 4:38 PM
Quuxplusone added a subscriber: Quuxplusone.

LGTM, but (re @zoecarver's comment)
Please do not mark this as "NFC", since in fact it has a significant effect on semantics: it makes the operators hidden friends!
Hidden friends are hidden (from non-ADL lookup); non-hidden friends are not hidden from non-ADL name lookup.
@zoecarver, an example program (which we are deliberately breaking and that's fine) would be, like, https://godbolt.org/z/75jM676hx

template<class T>
void f(bool (*fp)(T, std::partial_ordering)) {}

int main() {
    f(std::operator<);
}
This revision is now accepted and ready to land.May 10 2021, 4:38 PM