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);
nothrow .Algebraic.get alternative that returns an algebraic subset.