Mark said:
Memberwise comparison worked pretty well in C++. An object is equal to
another object if all its members are equal to the other object's members
(using the same criterion for member equality).
Usually, but not always.
I have a faint memory of reading somewhere that the decision to not
include an automatic memberwise comparison for structs was that it would
automatically add functionality to all structs that you create. If the
comparison doesn't make sense for a struct, you would be forced to
override it even if it didn't make sense to compare the structs at all.
It would not be possible to prevent usage of the comparison at compile
time, it could only throw an exception at run time.
If you want a memberwise comparison for a struct, it's very easy to
write one, and you can most likely make it more efficient than any
automatically generated code, as you can choose the order to compare the
fields so that you first compare the fields that is most likely to differ.