safeOp.abs

Get the absolute value of num.

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

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

Examples

1 import checkedint.sticky : safeOp; // use IntFlagPolicy.sticky
2 
3 assert(safeOp.abs(-25) == 25);
4 assert(safeOp.abs(745u) == 745u);
5 
6 safeOp.abs(int.min);
7 assert(IntFlags.local.clear() == IntFlag.posOver);

Meta