BigInt.opCast

Implements casting to integer types.

  1. T opCast()
  2. T opCast()
    struct BigInt
    pure @safe const
    T
    opCast
    (
    T : ulong
    )
    ()
  3. T opCast()
  4. T opCast()

Throws

std.conv.ConvOverflowException if the number exceeds the target type's range.

Examples

import std.conv : to, ConvOverflowException;
import std.exception : assertThrown;

assert(BigInt("0").to!int == 0);

assert(BigInt("0").to!ubyte == 0);
assert(BigInt("255").to!ubyte == 255);
assertThrown!ConvOverflowException(BigInt("256").to!ubyte);
assertThrown!ConvOverflowException(BigInt("-1").to!ubyte);

Meta