vibe.d beta banner
get vibe.d
0.8.5

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

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

Sönke Ludwig

Copyright

Copyright 2015-2019, Sönke Ludwig.

License

www.boost.org/LICENSE_1_0.txt, Boost License 1.0.