Rewriting Expressions
Explore how C++20's spaceship operator rewrites all six comparison operators into a unified form. Understand the compiler's role in handling symmetrical comparisons and implicit conversions when rewriting expressions. Learn practical examples that clarify this new approach to comparisons.
We'll cover the following...
We'll cover the following...
When the compiler sees something such as a < b, it rewrites it to (a <=> b) < 0 using the spaceship operator. Of course, the rule applies to all six comparison operators:
a OP b becomes (a <=> b) OP 0. It’s even better. If there is no ...