IntrusivePtr.opAssign

Releases the ownership of the managed object, if any.

After the call, this manages no object.

  1. void opAssign(typeof(null) nil)
    struct IntrusivePtr
    scope
    void
    opAssign
    (
    MemoryOrder order = MemoryOrder.seq
    this This
    )
    (
    typeof(null) nil
    )
    if (
    isMutable!This
    )
  2. void opAssign(Rhs desired)

Examples

static struct Foo{
    ControlBlock!(int, int) c;
    int i;

    this(int i)pure nothrow @safe @nogc{
        this.i = i;
    }
}

{
    IntrusivePtr!Foo x = IntrusivePtr!Foo.make(1);

    assert(x.useCount == 1);
    x = null;
    assert(x.useCount == 0);
    assert(x == null);
}

{
    IntrusivePtr!(shared Foo) x = IntrusivePtr!(shared Foo).make(1);

    assert(x.useCount == 1);
    x = null;
    assert(x.useCount == 0);
    assert(x == null);
}

{
    shared IntrusivePtr!(shared Foo) x = IntrusivePtr!(shared Foo).make(1);

    assert(x.useCount == 1);
    x = null;
    assert(x.useCount == 0);
    assert(x.load == null);

}

Meta