Is this standard behavior in C++20? I couldn't find anything about it in cppreference.
I've just tried both on Clang and on Visual Studio and it works and it doesn't give me any sort of error or warning. I also checked with the debugger to see if operator== was being called and it was! Does C++20 now allows for the automatic generation of operator!= when operator== is present? Does it default to a sane !(a == b)? If that's so, then that's awesome for C++!
Yes.
operator!=is auto generated fromoperator==in C++20.Furthermore, all four relational operators are generated if you define
operator<=>, and all of the comparison operators are generated if you defineoperator<=>as defaulted.What you want to do in most cases: