import checkedint.noex : safeOp; // safeOp.cmp() never throws assert(safeOp.cmp!"=="(int.max, 0x7FFF_FFFF)); assert(safeOp.cmp!"!="(uint.min, 5u)); assert(safeOp.cmp!"<="(int.min, 0)); static assert(!__traits(compiles, safeOp.cmp!"=="(uint.max, -1))); static assert(!__traits(compiles, safeOp.cmp!">"(-1, 1u)));
Compare left and right using op.
Unsafe signed/unsigned comparisons will trigger a compile-time error. Possible solutions include:
Direct comparisons between boolean values and numeric ones are also forbidden. Make your intention explicit: