The OpenD Programming Language

Warn.hookOpCmp

Called automatically upon a comparison for ordering using one of the operators <, <=, >, or >=. In case the comparison is erroneous (i.e. it would make a signed negative value appear greater than or equal to an unsigned positive value), then a warning message is printed to stderr.

struct Warn
static
int
hookOpCmp
(
Lhs
Rhs
)
(
Lhs lhs
,
Rhs rhs
)

Parameters

lhs Lhs

The first argument of Checked, e.g. int if the left-hand side of the operator is Checked!int

rhs Rhs

The right-hand side type involved in the operator

Return Value

Type: int

In all cases, returns lhs < rhs ? -1 : lhs > rhs. The result is not autocorrected in case of an erroneous comparison.

Examples

auto x = checked!Warn(-42);
// Passes
assert(x <= -42);
// Passes but prints a warning
// assert(x <= uint(-42));

Meta