Why can I invoke == with a defaulted <=> but not a user-provided one?
问题 #include <compare> struct A { int n; auto operator <=>(const A&) const noexcept = default; }; struct B { int n; auto operator <=>(const B& rhs) const noexcept { return n <=> rhs.n; } }; int main() { A{} == A{}; // ok B{} == B{}; // error: invalid operands to binary expression } compiled with clang-10 as clang -std=c++20 -stdlib=libc++ main.cpp Why does A{} == A{} work but not B{} == B{} ? 回答1: In the original design of the spaceship operator, == is allowed to call <=> , but this is later