SmartInt.opAssign

Assign the value of that to this SmartInt instance.

checkedint.to() is used to verify that >= N.min && that <= N.max. If not, an IntFlag will be raised.

  1. this(M that)
  2. typeof(this) opAssign(M that)
    struct SmartInt(N, IntFlagPolicy _policy, Flag!"bitOps" bitOps = Yes.bitOps)
    ref
    typeof(this)
    opAssign
    (
    M
    )
    (
    const M that
    )
    if (
    isScalarType!M
    )
    if (
    isIntegral!N &&
    )

Examples

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

// Any basic scalar or checkedint *type* is accepted...
SmartInt!int n = 0;
n = cast(ulong)0;
n = cast(dchar)0;
n = cast(byte)0;
n = cast(real)0;
assert(!IntFlags.local);

// ...but not any *value*.
n = uint.max;
n = long.min;
n = real.nan;
assert(IntFlags.local.clear() == (IntFlag.posOver | IntFlag.negOver | IntFlag.undef));

Meta