SafeInt.opCast

Convert this value to floating-point. This always succeeds, although some loss of precision may occur if M.sizeof <= N.sizeof.

  1. M opCast()
    struct SafeInt(N, IntFlagPolicy _policy, Flag!"bitOps" bitOps = Yes.bitOps)
    M
    opCast
    const pure @safe nothrow @nogc
    (
    M
    )
    (
    )
    if (
    isFloatingPoint!M
    )
    if (
    isIntegral!N &&
    isUnqual!N
    )
  2. M opCast()
  3. M opCast()

Examples

1 import checkedint.throws : SafeInt; // use IntFlagPolicy.throws
2 
3 SafeInt!int n = 92;
4 auto f = cast(double)n;
5 static assert(is(typeof(f) == double));
6 assert(f == 92.0);

Meta