Ordering before C++20
Explore how ordering comparisons were traditionally implemented in C++ before the introduction of the three-way comparison operator in C++20. Learn about the challenges of defining multiple comparison operators manually and how the spaceship operator simplifies and automates this process, including differences in behavior for various data types.
We'll cover the following...
We'll cover the following...
The three-way comparison operator <=> is often called the spaceship operator. The spaceship operator determines for two values A and B, whether A < B, A == B, or A > B. You can define the spaceship operator, or the compiler can auto-generate it for you.
To appreciate the advantages of the three-way comparison operator, let me ...