4 ms·
The three-way comparison operator just needs to return a ternary, and many comparisons boil down to integer subtraction. strcmp is also defined this way. In C+
by sagarm 2y ago
The three-way comparison operator just needs to return a ternary, and many comparisons boil down to integer subtraction. strcmp is also defined this way.
In C++20 the compiler will automatically use the spaceship operator to implement other comparisons if it is available, so it's a significant convenience.