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.

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.

struct ProperCompare
static
hookOpCmp
(
L
R
)
(
L lhs
,
R rhs
)

Parameters

lhs L

The left-hand side of the comparison for ordering

rhs R

The right-hand side of the comparison for ordering

Return Value

Type: auto

The result of the comparison (negative if lhs < rhs, positive if lhs > rhs, 0 if the values are equal)

Meta