smartOp.bsr

core.bitop.bsr without the undefined behaviour. smartOp.bsr(0) will raise IntFlag.undef.

template smartOp(IntFlagPolicy policy)
@safe
ubyte
bsr
(
N
)
(
const N num
)

Examples

import checkedint.noex : smartOp;

assert(smartOp.bsr( 20) ==  4);
assert(smartOp.bsr(-20) == 31);

smartOp.bsr(0);
assert(IntFlags.local.clear() == IntFlag.undef);

Meta