nullable variant, null value is used if naryFun!visitors can't be called with provided arguments.
static struct S { int a; } Variant!(S, double) variant; alias optionalVisitInst = optionalVisit!((ref value) => value + 0); // do nothing because of variant isn't initialized Nullable!double result = optionalVisitInst(variant); assert(result.isNull); variant = S(2); // do nothing because of lambda can't compile result = optionalVisitInst(variant); assert(result == null); variant = 3.0; result = optionalVisitInst(variant); assert (result == 3.0);
Behaves as visit but doesn't enforce at compile time that all types can be handled by the visiting functions.