I always wondered why you have to overload both; couldn't the implementation of !=
be built-in to call ==
? Is there a reason where you'd want "quantum indeterminate equality", if you'd like to call it that - situations where both x == y
and x != y
are true, or both false?
Asked
Active
Viewed 73 times
4

Peter Duniho
- 68,759
- 7
- 102
- 136

ekolis
- 6,270
- 12
- 50
- 101
-
4Floating point has "quantum indeterminate equality" due to NaN. – Raymond Chen Aug 20 '16 at 20:42
-
2Define "practical". I've seen lots of crazy things in code, and some people would insist it makes the code better, more efficient, easier to write, or whatever. I could see someone claiming that they want to overload `==` to get an object-content-equality comparison, but want to leave `!=` so that they can do implicit reference-equality comparisons. The marked duplicate has lengthy discussion on the topic. If you really think you have a new question, please explain in detail why the existing questions on the topic don't address your particular concern. – Peter Duniho Aug 20 '16 at 21:06