Throw

Hook implementation that throws exceptions instead of default assert behavior.

Members

Static functions

onAccessEmptyError
void onAccessEmptyError()

Handler for case when empty error is accessed.

onAccessEmptyValue
void onAccessEmptyValue(E err)

Handler for case when empty value is accessed.

Static variables

enableDefaultConstructor
bool enableDefaultConstructor;

Default constructor for Expected is disabled. Same with the opAssign, so Expected can be only constructed once and not modified afterwards.

Examples

1 static assert(!isDefaultConstructorEnabled!Throw);
2 static assert(hasOnAccessEmptyValue!(Throw, string));
3 static assert(hasOnAccessEmptyValue!(Throw, int));
4 static assert(hasOnAccessEmptyError!Throw);
5 
6 assertThrown!(Unexpected!string)(ok!(string, Throw)(42).error);
7 assertThrown!(Unexpected!string)(err!(int, Throw)("foo").value);
8 assertThrown!(Unexpected!int)(err!(bool, Throw)(-1).value);

Meta