The comparison operator, must be either >, < , <= or >=. Equality is also allowed even if this is always a transparent operation.
The left operand, an integer.
The right operand, an integer.
A bool, the comparison result.
int a = -1; uint b; assert(a > b); // wrong result assert(compare!">"(a,b) == false); // fixed by operand widening assert(b < a); // wrong result assert(compare!"<"(b,a) == false); // fixed by operand widening long aa = -1; ulong bb; assert(aa > bb); // wrong result assert(compare!">"(aa,bb) == true); // not statically fixable assert(bb < aa); // wrong result assert(compare!"<"(bb,aa) == true); // not statically fixable assert(compare!"!="(bb,aa) == true); // test for equality is always transparent OP immutable long aaa = -1; const ulong bbb; assert(compare!">"(aaa,bbb) == true);
Compares two integral values with additional static checkings.
If the comparison mixes signed and unsigned operands then the function tries to widen the unsigned operand to perform a valid comparison, otherwise a DMD-style warning is emitted.