1 import checkedint.sticky : SafeInt; // use IntFlagPolicy.sticky 2 3 SafeInt!ulong n = 52uL; 4 auto a = cast(int)n; 5 static assert(is(typeof(a) == int)); 6 assert(!IntFlags.local); 7 assert(a == 52); 8 9 auto m = SafeInt!long(-1).mulPow2(n); 10 auto b = cast(wchar)m; 11 static assert(is(typeof(b) == wchar)); 12 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.