The OpenD Programming Language

nullable

Nullable Variant Type (aka Algebraic Type).

The implementation is defined as

alias Nullable(T...) = Variant!(typeof(null), T);

In additional to common algebraic API the following members can be accesssed:

Compatible with BetterC mode.

nullable
(
T
)
(
T t
)

Examples

Single type Nullable

static assert(is(Nullable!int == Variant!(typeof(null), int)));

Nullable!int a = 5;
assert(a.get!int == 5);

a.nullify;
assert(a.isNull);

a = 4;
assert(!a.isNull);
assert(a.get == 4);
assert(a == 4);
a = 4;

a = null;
assert(a == null);

Empty nullable type set support

Nullable!() a;
auto b = a;
assert(a.toHash == 0);
assert(a == b);
assert(a <= b && b >= a);
static assert(typeof(a).sizeof == 1);

Meta