Operator overloading or alternatives to expression templates

burjui via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 14 04:32:11 PDT 2015


On Sunday, 13 September 2015 at 17:16:40 UTC, Daniel N wrote:
> int opCmp(Foo rhs)
> {
>   return (id > rhs.id) - (id < rhs.id);
> }

IMO, subtracting boolean values is bad code style, it's better to 
be explicit about your intention:
> (id > rhs.id ? 1 : 0) - (id < rhs.id ? 1 : 0)


More information about the Digitalmars-d mailing list