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.
Function std.checkedint.WithNaN.hookOpBinaryRight
Defines hooks for binary operators +
, -
, *
, /
, %
, ^^
, &
, |
,
^
, <<
, >>
, and >>>
for cases where a Checked
object is the
right-hand side operand. If rhs == WithNaN
, returns
WithNaN
without evaluating the
operand. Otherwise, evaluates the operand. If evaluation does not overflow,
returns the result. Otherwise, returns WithNaN
.
auto hookOpBinaryRight(string x, L, R)
(
L lhs,
R rhs
);
Parameters
Name | Description |
---|---|
x | The operator symbol |
lhs | The left-hand side operand |
rhs | The right-hand side operand (Rhs is the first argument to Checked ) |
Returns
If rhs != WithNaN
and the operator does not
overflow, the function returns the same result as the built-in operator. In
all other cases, returns WithNaN
.
Example
Checked!(int, WithNaN) x;
assert((1 + x) .isNaN);
x = 100;
assert(!(1 + x) .isNaN);
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.