Module std.sumtype
[SumType] is a generic discriminated union implementation that uses design-by-introspection to generate safe and efficient code. Its features
include
* [Pattern matching.][match]
* Support for self-referential types.
* Full attribute correctness (pure, @safe, @nogc, and nothrow are
    inferred whenever possible).
* A type-safe and memory-safe API compatible with DIP 1000 (scope).
* No dependency on runtime type information (TypeInfo).
* Compatibility with BetterC.
Example
Basic usage
import stdExample
Introspection-based matching
 In the length and horiz functions below, the handlers for match do not
 specify the types of their arguments. Instead, matching is done based on how
 the argument is used in the body of the handler: any type with x and y
 properties will be matched by the rect handlers, and any type with r and
 theta properties will be matched by the polar handlers.
import stdExample
Arithmetic expression evaluator
 This example makes use of the special placeholder type This to define a
 [recursive data type](https://en.wikipedia.org/wiki/Recursive_data_type): an
 [abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) for
 representing simple arithmetic expressions.
import stdClasses
| Name | Description | 
|---|---|
| 
									MatchException
								 | Thrown by [tryMatch] when an unhandled type is encountered. | 
Structs
| Name | Description | 
|---|---|
| 
									SumType
								 | A [tagged union](https://en.wikipedia.org/wiki/Tagged_union) that can hold a single value from any of a specified set of types. | 
| 
									This
								 | Placeholder used to refer to the enclosing [SumType]. | 
Templates
| Name | Description | 
|---|---|
| 
									match
								 | Calls a type-appropriate function with the value held in a [SumType]. | 
| 
									tryMatch
								 | Attempts to call a type-appropriate function with the value held in a [SumType], and throws on failure. | 
Manifest constants
| Name | Type | Description | 
|---|---|---|
| canMatch | True if handleris a potential match forTs, otherwise false. | |
| isSumType | True if Tis a [SumType] or implicitly converts to one, otherwise false. | 
Authors
Paul Backus
License
Boost License 1.0