WAT: opCmp and opEquals woes

via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 26 06:25:05 PDT 2014


On Saturday, 26 July 2014 at 10:22:54 UTC, Fool wrote:
> I agree that the documentation needs improvement.
>
> It needs to be defined what kind of relation opCmp is meant to 
> model.
>
> If it's concept is a partial order, opEquals cannot be inferred.
>
> If it's concept is a strict weak ordering [1, 2], which is 
> required for sorting, opEqual can be inferred.

I don't think so.

NaN < x is false
NaN > x is false

if you try to derive equality from that you would get:

NaN == x is true

For sorting you are obviously better off defining NaN as in a 
manner that is consistent with the other values of the type. E.g. 
preceding all other float values.


More information about the Digitalmars-d mailing list