DEV Community

Discussion on: Do we correctly calculate min and max?

Collapse
 
phlash profile image
Phil Ashby

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:

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.

Collapse
 
sandordargo profile image
Sandor Dargo

Thanks, I'm going to check it out!