Sourceroot/optional.d
Documentationhttps://dlang.org/phobos/dmd_root_optional.html
import core.exception : AssertError;Optional!int opt;assert( opt.isEmpty());assert(!opt.isPresent());assert(!opt.hasValue(1));assert(!opt.hasValue(2));bool caught;trycast(void) opt.get();catch (AssertError) caught =true;assert(caught);opt = Optional!int(1);assert(!opt.isEmpty());assert( opt.isPresent());assert( opt.get() == 1);assert( opt.hasValue(1));assert(!opt.hasValue(2));
Optional(T);value);create(Tval);isPresent() const;isEmpty() const;get() inout;hasValue(const Texp) const;