safeInt

Get the value of num as a SafeInt!N. The integral type N can be infered from the argument.

SafeInt!(N, policy, bitOps)
safeInt
@safe
(
Flag!"bitOps" bitOps = Yes.bitOps
N
)
(
N num
)
if (
isIntegral!N ||
isCheckedInt!N
)

Examples

1 import checkedint.throws : safeInt, SafeInt; // use IntFlagPolicy.throws
2 
3 auto a = safeInt(55uL);
4 static assert(is(typeof(a) == SafeInt!ulong));
5 assert(a == 55u);

Meta