重载!= as ==否定

Dar*_*ros 5 c++ operator-overloading

我有一段代码实现了==重载.我不得不在某个否定的地方使用它.但是!(A == B)对于读者而言,写作似乎并不清楚.所以我实现了这个双重重载.这样做有什么缺点吗?效率明智吗?:

struct Foo{
  bool operator==(const Foo& other) const{
      .... //Something that sometimes produces "return false"
      return true;
  }
  bool operator!=(const Foo& other) const{
      return !(*this == other);
  }
}
Run Code Online (Sandbox Code Playgroud)

额外:为什么编译器没有!=使用否定的默认实现==