opCmp, [partial/total/pre]orders, custom floating point types etc.

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 13:02:49 PST 2016


On Tuesday, 12 January 2016 at 20:52:51 UTC, Timon Gehr wrote:
> On 01/12/2016 07:27 PM, John Colvin wrote:
>> ...
>
>
> struct S{
>     auto opCmp(S rhs){ return float.nan; }
>     bool opEquals(S rhs){ return false; }
> }
>
> unittest{
>     S a,b;
>     assert(!(a==b));
>     assert(!(a<b));
>     assert(!(a<=b));
>     assert(!(a>b));
>     assert(!(a>=b));
> }

what about classes and Object.opCmp?


More information about the Digitalmars-d mailing list