SumType

A tagged union that can hold a single value from any of a specified set of types.

The value in a SumType can be operated on using pattern matching.

The special type This can be used as a placeholder to create self-referential types, just like with Algebraic. See the "Arithmetic expression evaluator" example for usage.

A SumType is initialized by default to hold the .init property of its first member type, just like a regular union.

struct SumType (
TypeArgs...
) if (
TypeArgs.length > 0 &&
TypeArgs.length < size_t.max
) {}

Constructors

this
this(inout(T) val)

Constructs a SumType holding a specific value.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Aliases

Types
alias Types = AliasSeq!(ReplaceType!(This, typeof(this), TypeArgs))

The types a SumType can hold.

Functions

opAssign
void opAssign(T rhs)

Assigns a value to a SumType.

See Also

std.variant.Algebraic

Meta