Warn

Hook that prints to stderr a trace of all integral errors, without affecting default behavior.

Members

Static functions

hookOpCmp
int hookOpCmp(Lhs lhs, Rhs rhs)

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.

hookOpEquals
bool hookOpEquals(Lhs lhs, Rhs rhs)

Called automatically upon a comparison for equality. In case of an Erroneous comparison (one that would make a signed negative value appear equal to an unsigned positive value), writes a warning message to stderr as a side effect.

onBadCast
Dst onBadCast(Src src)

Called automatically upon a bad cast from src to type Dst (one that loses precision or attempts to convert a negative value to an unsigned type).

onLowerBound
T onLowerBound(Rhs rhs, T bound)

Called automatically upon a bad opOpAssign call (one that loses precision or attempts to convert a negative value to an unsigned type).

onOverflow
typeof(~Lhs()) onOverflow(Lhs lhs)
typeof(Lhs() + Rhs()) onOverflow(Lhs lhs, Rhs rhs)

Called automatically upon an overflow during a unary or binary operation.

onUpperBound
T onUpperBound(Rhs rhs, T bound)

Called automatically upon a bad opOpAssign call (one that loses precision or attempts to convert a negative value to an unsigned type).

Examples

auto x = checked!Warn(42);
short x1 = cast(short) x;
//x += long(int.max);
auto y = checked!Warn(cast(const int) 42);
short y1 = cast(const byte) y;

Meta