C++ Logo

std-proposals

Advanced search

[std-proposals] Let spaceship return an int

From: Chris Gary <cgary512_at_[hidden]>
Date: Sat, 23 Sep 2023 09:45:22 -0600
All computable data can be made isomorphic to integers.
It is always possible to define a total ordering.
Even N-d points have a total ordering in the form of space-filling curves.
N-d rational points are the same: Reduce the coordinates so they are
unique, then either use zig-zag or interleave the bits numerator then
denominator to get a Morton index for some weird N+1 or 2*N dimensional
space (not the same in the spatial sense, but this at least allows them to
be used in an ordered container).

For all scalar types, spaceship could become int-valued and return the sign
of the difference in the form of an int.

Let the ordering in the case of an 'int'-valued operator <=> be assumed the
same as std::strong_order where it is not otherwise defined explicitly.

In the context of deducing the result type of operator <=>, it could be
allowed either for backwards compatibility. That, or implicit "cast" of
"int" to a "std::strong_order" where it is required.

Frankly, I've avoided using operator <=> due to header issues and the
strangeness of a formal operator returning a privileged type in namespace
std. I wouldn't be surprised if I've missed a detail...

Received on 2023-09-23 15:45:34