The return type of tryVisit is deduced from the visiting functions and must be the same across all overloads.
VariantException if variant doesn't hold a value or variant holds a value which isn't handled by the visiting functions, when no parameter-less fallback function is specified.
Algebraic!(int, string) variant; variant = 10; auto which = -1; variant.tryVisit!((int i) { which = 0; })(); assert(which == 0); // Error function usage variant = "test"; variant.tryVisit!((int i) { which = 0; }, () { which = -100; })(); assert(which == -100);
Behaves as visit but doesn't enforce that all types are handled by the visiting functions.
If a parameter-less function is specified it is called when either variant doesn't hold a value or holds a type which isn't handled by the visiting functions.