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