Report a bug
If you spot a problem with this page, click here to create a Github issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.variant

This module implements a generic variant type.
struct Variant(Types...) if (Types.length);
Variant Type (aka Algebraic Type) with clever member access.
Compatible with BetterC mode.
this(typeof(null));
void opAssign(typeof(null));
const nothrow @property bool empty();
Returns:
true for the unassigned instance.
const nothrow @property uint typeId();
Returns:
zero if the instance is unassigned and type index starting with 1 otherwise.
template visit(alias visitor, bool forceAllTypes = true)
Parameters:
visitor a function name alias
forceAllTypes if true checks at compile time, that the member can be called for all types.
ref auto visit(V, Args...)(auto ref V variant, auto ref Args args)
if (is(Unqual!V : Variant!Types, Types));
template optionalVisit(alias visitor)
Parameters:
visitor a function name alias
bool optionalVisit(Result, V, Args...)(out Result result, auto ref V variant, auto ref Args args)
if (is(Unqual!V : Variant!Types, Types));