Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions changelog/std-experimental-checkedint.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
New: Checked, a lightweight and highly configurable checked integral

$(REF Checked, std, experimental, checkedint) is a wrapper around any integral
type that inserts checks against common sources of bugs: overflow in operators,
mixed-sign comparisons, and casts that lose information.

The example below illustrates the basic use of the facility:

-------
void main()
{
import std.experimental.checkedint, std.stdio;
writeln((checked(5) + 7).get); // 12
writeln((checked(10) * 1000 * 1000 * 1000).get); // Overflow
}
-------

By default, all checks are enabled and the program is aborted if any check
fails. An implementation based on hooks discoverable by using Design by
Introspection allows unbounded customizations of both the checks to do, and the
enforcement policy.