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.
							
						Struct std.experimental.checkedint.WithNaN
Hook that reserves a special value as a "Not a Number" representative. For
signed integrals, the reserved value is T. For signed integrals, the
reserved value is T.
						
				struct WithNaN
				;
						
					
				The default value of a Checked!(X, WithNaN) is its NaN value, so care must
be taken that all variables are explicitly initialized. Any arithmetic and logic
operation involving at least on NaN becomes NaN itself. All of a == b, a < b, a > b, a <= b, a >= b yield false if at least one of
a and b is NaN.
Methods
| Name | Description | 
|---|---|
| hookOpBinary(lhs, rhs) | Defines hooks for binary operators +,-,*,/,%,^^,&,|,^,<<,>>, and>>>for cases where aCheckedobject is the
    left-hand side operand. Iflhs == WithNaN, returnsWithNaNwithout evaluating the
    operand. Otherwise, evaluates the operand. If evaluation does not overflow,
    returns the result. Otherwise, returnsWithNaN. | 
| hookOpBinaryRight(lhs, rhs) | Defines hooks for binary operators +,-,*,/,%,^^,&,|,^,<<,>>, and>>>for cases where aCheckedobject is the
    right-hand side operand. Ifrhs == WithNaN, returnsWithNaNwithout evaluating the
    operand. Otherwise, evaluates the operand. If evaluation does not overflow,
    returns the result. Otherwise, returnsWithNaN. | 
| hookOpCast(rhs) | If rhsisWithNaN, returnsWithNaN. Otherwise, returnscast(Lhs) rhs. | 
| hookOpCmp(lhs, rhs) | If lhs == WithNaN, returnsdouble. Otherwise,
    has the same semantics as the default comparison. | 
| hookOpEquals(lhs, rhs) | Returns falseiflhs == WithNaN,lhs == rhsotherwise. | 
| hookOpOpAssign(lhs, rhs) | Defines hooks for binary operators +=,-=,*=,/=,%=,^^=,&=,|=,^=,<<=,>>=, and>>>=for cases where aCheckedobject is the left-hand side operand. Iflhs ==
    WithNaN, no action is carried. Otherwise, evaluates the
    operand. If evaluation does not overflow and fits inLhswithout loss of
    information or change of sign, setslhsto the result. Otherwise, setslhstoWithNaN. | 
| hookOpUnary(v) | Defines hooks for unary operators -,~,++, and--. | 
Example
auto x1 = Checked!(int, WithNaN)();
assert(x1Authors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.