SmartInt.opCast

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 SmartInt.

  1. M opCast()
  2. M opCast()
  3. M opCast()
    struct SmartInt(N, IntFlagPolicy _policy, Flag!"bitOps" bitOps = Yes.bitOps)
    const @safe
    M
    opCast
    (
    M
    )
    ()
    if (
    isIntegral!M
    ||
    isSomeChar!M
    )
    if (
    isIntegral!N &&
    )

Examples

import checkedint.sticky : SmartInt; // use IntFlagPolicy.sticky

SmartInt!ulong n = 52;
auto a = cast(int)n;
static assert(is(typeof(a) == int));
assert(!IntFlags.local);
assert(a == 52);

auto m = SmartInt!long(-1).mulPow2(n);
auto b = cast(wchar)m;
static assert(is(typeof(b) == wchar));
assert(IntFlags.local.clear() == IntFlag.negOver);

Meta