matchMember

Applies a member handler to the given Variant depending on the held type, ensuring that all types are handled by the visiting handler.

Fuses algebraic types on return.

alias matchMember(string member) = visitImpl!(getMemberHandler!member, Exhaustive.compileTime, true)

Examples

static struct S
{
    Nullable!int m;
}

static struct C
{
    Variant!(float, double) m;
}

alias V = Variant!(S, C);

V x = S(2.nullable);
V y = C(Variant!(float, double)(4.0));

// getMember returns an algebraic of algebaics
static assert(is(typeof(x.getMember!"m") == Variant!(Variant!(float, double), Nullable!int)));
// matchMember returns a fused algebraic
static assert(is(typeof(x.matchMember!"m") == Nullable!(int, float, double)));
assert(x.matchMember!"m" == 2);
assert(y.matchMember!"m" != 4);
assert(y.matchMember!"m" == 4.0);

Meta