View source code
Display the source code in std/checkedint.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Struct std.checkedint.Warn

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

struct Warn ;

Methods

NameDescription
hookOpCmp (lhs, 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 (lhs, 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 (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 (rhs, bound) Called automatically upon a bad opOpAssign call (one that loses precision or attempts to convert a negative value to an unsigned type).
onOverflow (lhs) Called automatically upon an overflow during a unary or binary operation.
onUpperBound (rhs, bound) Called automatically upon a bad opOpAssign call (one that loses precision or attempts to convert a negative value to an unsigned type).

Example

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;

Authors

License