View source code
							
							
						
								Display the source code in std/experimental/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.
							
						std.experimental.checkedint.Checked/checked  - multiple declarations
				Function checked
Convenience function that turns an integral into the corresponding Checked
instance by using template argument deduction. The hook type may be specified
(by default Abort).
						
					
				Example
static assert(is(typeof(checked(42)) == Checked!int));
writeln(checked(42)); // Checked!int(42)
static assert(is(typeof(checked!WithNaN(42)) == Checked!(int, WithNaN)));
writeln(checked!WithNaN(42)); // Checked!(int, WithNaN)(42)
Struct Checked
Checked integral type wraps an integral T and customizes its behavior with the
help of a Hook type. The type wrapped must be one of the predefined integrals
(unqualified), or another instance of Checked.
						
				struct Checked(T, Hook)
				
				  
				
				if (isIntegral!T || is(T == Checked!(U, H), U, H));
						
					
				Constructors
| Name | Description | 
|---|---|
| this | Constructor taking a value properly convertible to the underlying type. Umay be either an integral that can be converted toTwithout a loss, or
    anotherCheckedinstance whose representation may be in turn converted toTwithout a loss. | 
Fields
| Name | Type | Description | 
|---|---|---|
| hook | Hook | hookis a member variable if it has state, or an alias forHookotherwise. | 
Methods
| Name | Description | 
|---|---|
| get | Returns a copy of the underlying value. | 
| opAssign | Assignment operator. Has the same constraints as the constructor. | 
| opBinary | Defines binary operators +,-,*,/,%,^^,&,|,^,<<,>>,
    and>>>. IfHookdefineshookOpBinary,opBinaryforwards to    Checked!(typeof(hook. | 
| opBinaryRight | Defines binary operators +,-,*,/,%,^^,&,|,^,<<,>>, and>>>for the case when a built-in numeric or Boolean type is on
    the left-hand side, and aCheckedinstance is on the right-hand side. | 
| opCast | Casting operator to integral, bool, or floating point type. IfHookdefineshookOpCast, the call immediately returnshook. Otherwise, casting toboolyields    get != 0and casting to another integral that can represent all
    values ofTreturnsgetpromoted toU. | 
| opCmp | Compares thisagainstrhsfor ordering. IfHookdefineshookOpCmp,
    the function forwards tohook. Otherwise, the
    result of the built-in comparison operation is returned. | 
| opEquals | Compares thisagainstrhsfor equality. IfHookdefineshookOpEquals, the function forwards to    hook. Otherwise, the result of the
    built-in operationget == rhsis returned. | 
| opOpAssign | Defines operators +=,-=,*=,/=,%=,^^=,&=,|=,^=,<<=,>>=, and>>>=. | 
| opUnary | Defines unary operators +,-,~,++, and--. Unary+is not
    overridable and always has built-in behavior (returnsthis). For the
    others, ifHookdefineshookOpUnary,opUnaryforwards to    Checked!(typeof(hook. | 
| toHash | Generates a hash for this. IfHookdefineshookToHash, the call
    immediately returnshook. IfHookdoes not
    implementhookToHash, but it has state, a hash will be generated for
    theHookusing the built-in function and it will be xored with the
    hash of thepayload. | 
Aliases
| Name | Description | 
|---|---|
| Representation | The type of the integral subject to checking. | 
Authors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.