import checkedint.sticky : SafeInt; // use IntFlagPolicy.sticky SafeInt!ulong n = 52uL; auto a = cast(int)n; static assert(is(typeof(a) == int)); assert(!IntFlags.local); assert(a == 52); auto m = SafeInt!long(-1).mulPow2(n); auto b = cast(wchar)m; static assert(is(typeof(b) == wchar)); assert(IntFlags.local.clear() == IntFlag.negOver);
Convert this value to type M using checkedint.to() for bounds checking. An IntFlag will be raised if M cannot represent the current value of this SafeInt.