Function std.experimental.checkedint.ProperCompare.hookOpCmp
Hook for <
, <=
, >
, and >=
that ensures comparison against integral
values has the behavior expected by the usual arithmetic rules. The built-in
semantics yield surprising behavior when comparing signed values against
unsigned values, for example 0u < -1
. The call hookOpCmp(x, y)
returns -1
if and only if x
is smaller than y
in abstract arithmetic
sense.
auto hookOpCmp(L, R)
(
L lhs,
R rhs
);
If one of the numbers is an integral and the other is a floating-point
number, hookOpEquals(x, y)
returns a floating-point number that is -1
if x < y
, 0
if x == y
, 1
if x > y
, and NaN
if the floating-point
number is NaN
.
Parameters
Name | Description |
---|---|
lhs | The left-hand side of the comparison for ordering |
rhs | The right-hand side of the comparison for ordering |
Returns
The result of the comparison (negative if lhs < rhs
, positive if lhs > rhs
, 0
if the values are equal)