Operator overloading or alternatives to expression templates

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 13 12:06:21 PDT 2015


On 09/13/2015 07:16 PM, Daniel N wrote:
> 
> Could you try this?
> 
> int opCmp(Foo rhs)
> {
>   return (id > rhs.id) - (id < rhs.id);
> }

That's not the point, opCmp requires twice as many comparisons as needed
for <. If they are more expansive, e.g. string comparison, your trick
won't work.


More information about the Digitalmars-d mailing list