Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |