Comparison operator overloading

Anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Dec 7 10:04:56 PST 2015


On Monday, 7 December 2015 at 17:18:20 UTC, Dominikus Dittes 
Scherkl wrote:
> Hmm. But it works just fine! It overloads also the special 
> floatingpoint operators <> !<> !<= and so on.

Those are deprecated: 
http://dlang.org/deprecate.html#Floating%20point%20NCEG%20operators

> And how else could I handle a self-defined type that happens to 
> have a NaN value (like my save-signed intergers do)?

Something like this:
http://dlang.org/phobos/std_math.html#isNaN

Or maybe this:
http://dlang.org/phobos/std_typecons.html#Nullable

Obviously, you'd want to do what makes sense for your type and 
its semantics. That probably doesn't involve using NCEG operators.


More information about the Digitalmars-d-learn mailing list