Equality operator overloads: Is (x!=y) == (!(x==y))?

后端 未结 3 1257
南方客
南方客 2021-01-17 07:49

Does the C++ standard guarantee that (x!=y) always has the same truth value as !(x==y)?


I know there are many subtleties inv

3条回答
  •  日久生厌
    2021-01-17 08:02

    No. You can write operator overloads for == and != that do whatever you wish. It probably would be a bad idea to do so, but the definition of C++ does not constrain those operators to be each other's logical opposites.

提交回复
热议问题