https://issues.dlang.org/show_bug.cgi?id=10490
Justin Whear <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from Justin Whear <[email protected]> --- I've been using this solution, perhaps it should be included in std.variant, though possibly with a better name: ---- import std.variant; import std.traits : isInstanceOf; /** * Calls the correct overload of Fun based on the runtime value of the Variant value. */ auto applyToAlgebraic(alias Fun, Value)(Value value) if (isInstanceOf!(VariantN, Value)) // Can we constrain to Algebraic only? { foreach (T; Value.AllowedTypes) // unrolled at CT if (typeid(T) is value.type) return Fun(value.get!T); assert(0); } ---- --
