The OpenD Programming Language

Algebraic.get

Gets an algebraic subset.

Members

Functions

get
auto ref get()

Throws

Exception if the storage contains value of the type that isn't represented in the allowed type set of the requested algebraic.

Examples

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

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

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

Meta