NotNull

NotNull ensures a null value can never be stored.

* You must initialize it when declared

* You must never assign the null literal to it (this is a compile time error)

* If you assign a null value at runtime to it, it will immediately throw an Error at the point of assignment.

NotNull!T can be substituted for T at any time, but T cannot become NotNull without some attention: either declaring NotNull!T, or using the convenience function, notNull.

Condition: T must be a reference type. Instead of: __traits(compiles, { T t; assert(t is null); } ).

TODO Merge with http://arsdnet.net/dcode/notnullsimplified.d

Constructors

this
this()
Undocumented in source.
this
this(T value)

Cast to bool. Constructs with a runtime not null check (via assert()).

this
this(typeof(null) )

Disable null construction.

Alias This

_valueHelper

Members

Functions

opAssign
typeof(this) opAssign(NotNull!U rhs)

Assignment from NotNull Inherited Class rhs to NotNull Base Class this.

opAssign
typeof(this) opAssign(typeof(null) )

Disable null assignment.

Properties

_valueHelper
NotNull!(BaseClassesTuple!T[0]) _valueHelper [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
_valueHelper
inout(T) _valueHelper [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
_valueHelper
inout(T) _valueHelper [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

int myInt;
NotNull!(int *) not_null = &myInt;
// you can now use variable not_null anywhere you would
// have used a regular int*, but with the assurance that
// it never stored null.

Meta