A more "old-school" version of visit. Provided both to conform style of existing code and avoid delegate bugs in dmd1.
Puts this into defined state
Puts this into undefined state
Interface to retrieve stored value. It is intentionally designed in a way that forces you to handle "undefined" state to avoid issues akin to "null pointer".
Alias to make code working with undefined state more readable
alias Optional!(bool) Maybe; Maybe x, y, z; x = true; y = false; z = Maybe.undefined; x.visit( () { test(false); }, (ref bool value) { test(value); } ); y.visit( () { test(false); }, (ref bool value) { test(!value); } ); z.visit( () { test(true); }, (ref bool value) { test(false); } );
ditto