Skip to content
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

Merged
merged 1 commit into from Jan 19, 2019

Conversation

Quuxplusone
Copy link
Contributor

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 the friend 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 spelling friend 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.

source/overloading.tex Outdated Show resolved Hide resolved
source/templates.tex Outdated Show resolved Hide resolved
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
Copy link
Contributor Author

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. :)

Copy link
Member

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").

source/overloading.tex Outdated Show resolved Hide resolved
Also one `operator<` that should at least have been a const member function.
@Quuxplusone
Copy link
Contributor Author

Ping.

@zygoloid zygoloid merged commit a9fdd85 into cplusplus:master Jan 19, 2019
@Quuxplusone Quuxplusone deleted the p0732 branch February 5, 2019 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants