safeOp.abs

Get the absolute value of num.

IntFlag.posOver is raised if N is signed and num == N.min.

template safeOp(IntFlagPolicy policy)
@safe
N
abs
(
N
)
(
const N num
)
if (
isIntegral!N ||
isBoolean!N
)

Examples

import checkedint.noex : safeOp; // use IntFlagPolicy.noex

assert(safeOp.abs(-25) == 25);
assert(safeOp.abs(745u) == 745u);

safeOp.abs(int.min);
assert(IntFlags.local.clear() == IntFlag.posOver);

Meta