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
[class.compare.secondary] The extent to which "The defaulted operator function is not considered" applies CWG2546 #5335
Comments
No, the emphasized wording is applied to both bullets. For the purpose of the definition of the defaulted comparison operator funciton, the operator function itself can't be considered as a candidate in any case. The second bullet is used in the following (bad-written) case: #include <compare>
struct C {
friend auto operator<=>(C, C) = default;
constexpr bool operator<(const C&) const { return false; }
friend bool operator<(C, C) = default; // deleted
};
// still well-formed if < is not used or only x.operator<(y) is used I think we can make the intent clearer by reordering:
|
That is what I have given in the third part of this issue. "Otherwise, the operator function yields x @ y." this sentence also should be reworded. |
Resulting in a usable candidate is not clear, see #5336. |
CWG2546 should address this in its suggested resolution. |
[class.compare.secondary] p2
Consider this example
The actual call at
#1
isC::operator<(C const&) const
, which is exposed by GCC and Clang. That is, they do consider the defaulted operator function as a candidate in the overload resolution for operator<
. Presumably, the emphasized wording is defined for the first bullet. Is it more clear to move the wording into the point after the first bullet?Another wording that is hard to read:
What does "the operator function yields x @ y" mean? GCC and Clang expose that the definition for the defaulted
operator<
function uses the call tooperator<=>(C const&, C const&)
. However, this behavior cannot be read from this wording. Presumably, the wording may mean thatSuch as the above example, since
operator <=>
is a usable candidate, according to [over.match.oper],x<y
is interpreted as(x <=> y) @ 0
, the effect of the defaultedoperator <
will behave the same as that of(x <=> y) @ 0
.The improvement to [class.compare.secondary] p2
The text was updated successfully, but these errors were encountered: