View source code Display the source code in std/typecons.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

std.typecons.nullable.get - multiple declarations

Function Nullable.get

Gets the value. this must not be in the null state. This function is also called for the implicit conversion to T.

Prototype

inout ref inout(T) get() pure nothrow @property @safe;

Returns

The value held internally by this Nullable.

Example

import std.exception: assertThrown, assertNotThrown;

Nullable!int ni;
//get is implicitly called. Will throw
//an AssertError in non-release mode
assertThrown!Throwable(ni == 0);

ni = 0;
assertNotThrown!Throwable(ni == 0);

Function Nullable.get

Gets the value. this must not be in the null state. This function is also called for the implicit conversion to T.

Prototype

inout ref inout(T) get() @property;

Returns

The value held internally by this Nullable.

Example

import std.exception: assertThrown, assertNotThrown;

Nullable!(int, -1) ni;
//get is implicitly called. Will throw
//an error in non-release mode
assertThrown!Throwable(ni == 0);

ni = 0;
assertNotThrown!Throwable(ni == 0);

Authors

Andrei Alexandrescu, Bartosz Milewski, Don Clugston, Shin Fujishiro, Kenji Hara

License

Boost License 1.0.

Comments