Explicit call of ternary compare

monarch_dodra monarchdodra at gmail.com
Mon Jul 23 07:32:15 PDT 2012


Is there any (efficient and correct) way to do ternary comparison 
on two objects?

You know the:
----
if(a<b) return -1;
if(b<a) return 1;
return 0;
----

I'm using the above method in a template, and the problem is that 
if a or b is a struct/class, this will resolve to 4 (!) calls to 
opCmp.



More information about the Digitalmars-d-learn mailing list