FlattenSumTypes

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.

To avoid ambiguity, duplicate types are not allowed (but see the "basic usage" example for a workaround).

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 value of its first member type, just like a regular union. The version identifier SumTypeNoDefaultCtor can be used to disable this behavior.

Members

Aliases

FlattenSumTypes
alias FlattenSumTypes = staticMap!(Impl, Types)
Undocumented in source.

Templates

Impl
template Impl(Type)
Undocumented in source.

Bugs

Types with @disabled opEquals overloads cannot be members of a SumType.

See Also

std.variant.Algebraic

Meta