The actual tryGet function.
the type of the value being accessed.
Basic usage
SumType!(string, double) example = "hello"; assert(example.tryGet!string == "hello"); double result = double.nan; try result = example.tryGet!double; catch (MatchException e) result = 0; // Exception was thrown assert(result == 0);
With type qualifiers
import std.exception: assertThrown; const(SumType!(string, double)) example = "const"; // Qualifier mismatch; throws exception assertThrown!MatchException(example.tryGet!string); // Qualifier matches; no exception assert(example.tryGet!(const(string)) == "const");
Attempt to access a SumType's value.
If the SumType does not contain a value of the specified type, an exception is thrown.