SharedPtr.opCast

Checks if this stores a non-null pointer, i.e. whether this != null.

  1. bool opCast()
    struct SharedPtr
    const scope pure nothrow @safe @nogc
    bool
    opCast
    (
    To : bool
    )
    ()
    if (
    is(To : bool)
    )
  2. To opCast()

Examples

SharedPtr!long x = SharedPtr!long.make(123);
assert(cast(bool)x);    //explicit cast
assert(x);              //implicit cast
x = null;
assert(!cast(bool)x);   //explicit cast
assert(!x);             //implicit cast

Meta