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
Fix some operator<=>
declarations with the wrong number of parameters
#2634
Conversation
source/classes.tex
Outdated
friend bool operator==(const C& x, const C& y) = default; // OK, returns \tcode{x <=> y == 0} | ||
bool operator<(const C&) = default; // OK, function is deleted | ||
friend bool operator==(const C&, const C&) = default; // OK, returns \tcode{x <=> y == 0} | ||
friend bool operator<(const C&, const C&) = default; // OK, function is deleted |
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.
The old version could also have been rescued by adding a trailing const
; but I am being no longer apologetic for my love of ADL friends. :)
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.
As a general rule, we do want to show different coding styles in the core section of the C++ standard. (That's different for the library seciton). So, showing "the other syntax" for operator< seems perfectly fine (yes, it needs a "const").
Also one `operator<` that should at least have been a const member function.
Ping. |
I noticed one of these mistakes while reading P0732R2; looks like when it was merged, the editor added the missing
operator<=>
(correctly) but left off thefriend
keyword (incorrectly).The other I found by grepping the source for "
operator<=>
".My understanding is that Herb Sutter's preferred spelling is
auto operator<=>(const T&) const = default;
— but that the alternative spellingfriend auto operator<=>(const T&, const T&) = default;
is also valid and has approximately the same semantics, and it's not a problem that some examples use one style and some the other.