30+ years of tech, retired from an identity intelligence company, now part-time with an insurance broker.
Dev community mod - mostly light gardening & weeding out spam :)
In particular Jonathan clearly describes the basis on which types in C++ can legitimately define an equality operator, and by extension a comparison operator (importantly for me, not like the weaker equivalence used in the Student example above). I particularly like his reference to the 'rule of least surprise', and his closing comment:
If you are not really sure what the value of your objects is, don’t define an operator==. A big sign of that is that you don’t actually have a copy operation for your type or it is not something mathematical.
This was interesting, thanks! I found the following series of blog posts enlightening on the mathematical basis of current C++ implementations:
foonathan.net/2018/06/equivalence-...
In particular Jonathan clearly describes the basis on which types in C++ can legitimately define an equality operator, and by extension a comparison operator (importantly for me, not like the weaker equivalence used in the
Student
example above). I particularly like his reference to the 'rule of least surprise', and his closing comment:Thanks, I'm going to check it out!