vibe.d beta banner
get vibe.d
0.10.1

Asynchronous I/O that doesn’t get in your way, written in D

Template tryVisit

The same as visit, except that failure to handle types is checked at runtime.

template tryVisit(VISITORS...) ;

Instead of failing to compile, tryVisit will throw an Exception if none of the handlers is able to handle the value contained in tu.

Contained Functions

NameDescription
tryVisit
tryVisit

Example

import std.exception : assertThrown;

union U {
	int number;
	string text;
}
alias TU = TaggedUnion!U;

auto tu = TU.number(42);
tu.tryVisit!((int n) { assert(n == 42); });
assertThrown(tu.tryVisit!((string s) { assert(false); }));
Authors
Copyright
License