In c++20, if I provide an operator== for a type, then the compiler synthesizes an operator!=, but not the other way around.
Here's some code:
struct A {};
bool operator==(A const&, A const&);
struct B {};
bool operator!=(B const&, B const&);
int main()
{
if (A{} != A{}) {} // error in c++17
// ok in c++20
if (B{} == B{}) {} // error in c++17
// error in c++20, why?
}
This seems inconsistent, since != and == are required to be contrary, and if one can be synthesized from the other, then the inverse should work too. What is the reason for this?