C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Let spaceship return an int

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Sat, 23 Sep 2023 20:43:32 +0100
On Sat, 23 Sept 2023, 16:45 Chris Gary via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> 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.
>


What does that mean for NaN <=> 1.0 ?



> 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...
>

That seems like a rather silly self-imposed limitation.

Received on 2023-09-23 19:43:48