On Tuesday, 20 July 2021 at 18:49:07 UTC, H. S. Teoh wrote:
On Tue, Jul 20, 2021 at 11:32:26AM -0700, Ali Çehreli via
Digitalmars-d-learn wrote:
On 7/19/21 11:20 PM, Tejas wrote:
> trying to create the spaceship operator of C++
Just to make sure, D's opCmp returns an int. That new C++
operator was added to provide the same semantics.
[...]
FYI, opCmp *may* return float, which may be useful sometimes
for implementing partial orders (return float.nan when two
elements are incomparable).
To be precise about it: `opCmp` must return a value that can be
compared with `0` using `<` and `>`. Any integer or
floating-point type will satisfy this requirement.