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.Throw
Force all integral errors to fail by throwing an exception of type
Throw. The message coming with the error is similar to the one
printed by Warn.
						
				struct Throw
				;
						
					
				Methods
| Name | Description | 
|---|---|
| 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), throws aThrowexception.
    Otherwise, the three-state result is returned (positive iflhs > rhs,
    negative iflhs < rhs,0otherwise). | 
| hookOpEquals(lhs, rhs) | Called automatically upon a comparison for equality. Throws upon an erroneous comparison (one that would make a signed negative value appear equal to an unsigned positive value). | 
| onBadCast(src) | Called automatically upon a bad cast (one that loses precision or attempts
    to convert a negative value to an unsigned type). The source type is Srcand the destination type isDst. | 
| onLowerBound(rhs, bound) | Called automatically upon a bounds error. | 
| onOverflow(lhs) | Called automatically upon an overflow during a unary or binary operation. | 
| onUpperBound(rhs, bound) | Called automatically upon a bounds error. | 
Inner classes
| Name | Description | 
|---|---|
| CheckFailure | Exception type thrown upon any failure. | 
Example
void test(T)()
{
    Checked!(int, Throw) x;
    x = 42;
    auto x1 = cast(T) x;
    writeln(x1); // 42
    x = TAuthors
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.