Confusion on the spaceship operator in C++20
C++20 introduces the Spaceship Operator (<=>) in P0515R3. For those who are unfamiliar with three-way comparison, the spaceship operator tests whether x < y, x = y, or x > y. As such, the _expression_
if (x <=> 1000)
is equivalent to
if (x < 1000 || x == 1000 || x > 1000)
. However, I don't see the point of this kind of comparison. Logic suggests that such a comparison will always be true, unless comparing floating-point representations (though such a representation is always imprecise). So can someone explain when exactly such an operator would actually be useful? From the proposed wording in section four of the paper, it seems like this is equivalent to something like Rusts std::cmp::Ordering or something like that.
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector