symmetric signed types

Dominikus Dittes Scherkl Dominikus.Scherkl at continental-corporation.com
Mon Jan 27 05:46:09 PST 2014


On Saturday, 25 January 2014 at 13:43:25 UTC, Timon Gehr wrote:
> Why not?
>
> struct S{
>     auto opCmp(S r){ return float.nan; }
> }
>
> void main(){
>     S s;
>     assert(s!<>=s);
> }

Yes, but only for floatingpoint types - you cannot overload the 
!<>= operator for integral types and it will be deprecated anyway.
And you cannot opverload opCmp in a way that the new defined 
integer NaN will not compare in some way to the other integer 
values.
What would be needed is a minimal signed type (2bit with the 
values -1, 0, 1 and NaN) and use that in opCmp.


More information about the Digitalmars-d mailing list