Nullable

A version of std.typecons.Nullable that reliably works with immutable data types.

Constructors

this
this(T value)

Construct a new Nullable!T.

Members

Functions

get
CopyConstness!(This, T) get()

Get the value stored previously. It is undefined to call this if no value is stored.

get
CopyConstness!(This, T) get(T default_)

Get the value stored previously. If no value is stored, default is returned.

isNull
bool isNull()

Return true if the Nullable!T does not contain a value.

nullify
void nullify()

If a value is stored, destroy it.

opAssign
void opAssign(T value)

Assign a new value.

opAssign
void opAssign(Nullable!T source)
opEquals
bool opEquals(Nullable other)

Examples

Nullable!(const int) ni;

assert(ni.isNull);

ni = 5;
assert(!ni.isNull);
assert(ni.get == 5);

ni.nullify;
assert(ni.isNull);

assert(ni == Nullable!(const int)());

Meta