WithNaN.hookOpOpAssign

Defines hooks for binary operators +=, -=, *=, /=, %=, ^^=, &=, |=, ^=, <<=, >>=, and >>>= for cases where a Checked object is the left-hand side operand. If lhs == WithNaN.defaultValue!Lhs, 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.defaultValue!Lhs.

struct WithNaN
static
void
hookOpOpAssign
(
string x
L
R
)
(
ref L lhs
,
R rhs
)

Parameters

x

The operator symbol (without the =)

lhs L

The left-hand side operand (Lhs is the first argument to Checked)

rhs R

The right-hand side operand

Return Value

Type: void

void

Examples

Checked!(int, WithNaN) x;
x += 4;
assert(x.isNaN);
x = 0;
x += 4;
assert(!x.isNaN);
x += int.max;
assert(x.isNaN);

Meta