SafeInt.bits

Get a view of this SafeInt that allows bitwise operations.

  1. inout(SafeInt!(N, policy, Yes.bitOps)) bits [@property getter]
    struct SafeInt(N, IntFlagPolicy _policy, Flag!"bitOps" bitOps = Yes.bitOps)
    @property ref return inout pure @safe nothrow @nogc
    static if(bitOps)
    inout(SafeInt!(N, policy, Yes.bitOps))
    bits
    ()
    if (
    isIntegral!N &&
    )
  2. SafeInt!(N, policy, Yes.bitOps) bits;

Examples

import checkedint.throws : SafeInt; // use IntFlagPolicy.throws

SafeInt!(int, No.bitOps) n = 1;
static assert(!__traits(compiles, n << 2));
assert(n.bits << 2 == 4);

Meta