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.hookOpOpAssign
Defines hooks for binary operators +=
, -=
, *=
, /=
, %=
, ^^=
,
&=
, |=
, ^=
, <<=
, >>=
, and >>>=
for cases where a Checked
object is the left-hand side operand. If lhs ==
WithNaN
, no action is carried. Otherwise, evaluates the
operand. If evaluation does not overflow and fits in Lhs
without loss of
information or change of sign, sets lhs
to the result. Otherwise, sets
lhs
to WithNaN
.
void hookOpOpAssign(string x, L, R)
(
ref L lhs,
R rhs
);
Parameters
Name | Description |
---|---|
x | The operator symbol (without the = ) |
lhs | The left-hand side operand (Lhs is the first argument to Checked ) |
rhs | The right-hand side operand |
Returns
void
Example
Checked!(int, WithNaN) x;
x += 4;
assert(x .isNaN);
x = 0;
x += 4;
assert(!x .isNaN);
x += int .max;
assert(x .isNaN);
}
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.