safeOp.bsf

core.bitop.bsf without the undefined behaviour. safeOp.bsf(0) will raise IntFlag.undef.

template safeOp(IntFlagPolicy policy)
int
bsf
@safe
(
N
)
(
const N num
)
if (
isFixedPoint!N
)

Examples

1 import checkedint.sticky : safeOp; // use IntFlagPolicy.sticky
2 
3 assert(safeOp.bsf(20) == 2);
4 
5 safeOp.bsf(0);
6 assert(IntFlags.local.clear() == IntFlag.undef);

Meta