User-defined and Auto-generated Comparison Operators

Visualize the interplay of user-defined and auto-generated operators with an example.

When you can define one of the six comparison operators and also auto-generate all of them using the spaceship operator, there is one question: Which one has the higher priority? For example, the implementation MyInt has a user-defined less than and equal to operator and also the compiler-generated six comparison operators. Let’s see what happens.

Get hands-on with 1400+ tech skills courses.