Exception if member can't be accessed with provided arguments
static struct S { int bar(int a) { return a; }} static struct C3 { alias Bar = (double a) => a * 2; } alias V = Variant!(S, C3); V x = S(); V y = C3(); static assert(is(typeof(x.tryGetMember!"bar"(2)) == int)); static assert(is(typeof(y.tryGetMember!"Bar"(2)) == double)); assert(x.tryGetMember!"bar"(2) == 2); assert(y.tryGetMember!"Bar"(2) == 4.0);
alias Number = Variant!(int, double); Number x = Number(23); Number y = Number(1.0); assert(x.visit!((int v) => true, (float v) => false)); assert(y.visit!((int v) => false, (float v) => true));
Behaves as getMember but doesn't enforce at compile time that all types can be handled by the member visitor.