Algebraic.trustedGet

nothrow .Algebraic.get alternative that returns an algebraic subset.

  1. auto ref trustedGet()
    template trustedGet(RetTypes...)
    ref return
    trustedGet
    (
    this This
    )
    ()
    if (
    RetTypes.length > 1
    )
  2. auto ref trustedGet()
  3. alias trustedGet(Kind kind) = trustedGet!(AllowedTypes[kind])
  4. auto ref trustedGet()

Members

Functions

trustedGet
auto ref trustedGet()

Examples

alias Float = Variant!(float, double);
alias Int = Variant!(long, int);
alias Number = Variant!(Float.AllowedTypes, Int.AllowedTypes);

Number number = 3.0;
assert(number._is!Float);
auto fp = number.trustedGet!Float;
static assert(is(typeof(fp) == Float));
assert(fp == 3.0);

// type list overload
number = 12L;
assert(number._is!(int, long));
auto integer = number.trustedGet!(int, long);
static assert(is(typeof(integer) == Int));
assert(integer == 12L);

Meta