WithNaN.hookOpUnary

auto hookOpUnary(string x, T)(ref T v)

Defines hooks for unary operators `-`, `~`, `++`, and `--`.

For `-` and `~`, if v == WithNaN.defaultValue!T, returns WithNaN.defaultValue!T. Otherwise, the semantics is the same as for the built-in operator.

For `++` and `--`, if v == WithNaN.defaultValue!Lhs or the operation would result in an overflow, sets v to WithNaN.defaultValue!T. Otherwise, the semantics is the same as for the built-in operator.

Parameters

xThe operator symbol
vThe left-hand side of the comparison (T is the first argument to Checked)

Returns

  • For x == "-" || x == "~": If v ==

    WithNaN.defaultValue!T, the function returns WithNaN.defaultValue!T. Otherwise it returns the normal result of the operator.

  • For x == "++" || x == "--": The function returns void.