View source code
Display the source code in std/sumtype.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla 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
local clone.
Template std.sumtype.tryMatch
Attempts to call a type-appropriate function with the value held in a [SumType], and throws on failure.
template tryMatch(handlers...)
;
Matches are chosen using the same rules as [match], but are not required to be exhaustive—in other words, a type (or combination of types) is allowed to have no matching handler. If a type without a handler is encountered at runtime, a [MatchException] is thrown.
Not available when compiled with -betterC
.
Contained Functions
Name | Description |
---|---|
tryMatch | The actual tryMatch function.
|
Returns
The value returned from the handler that matches the currently-held type, if a handler was given for that type.
Throws
[MatchException], if the currently-held type has no matching handler.
See Also
Authors
Paul Backus
License
Boost License 1.0
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.