SharedPtr.opAssign

Releases the ownership of the managed object, if any.

After the call, this manages no object.

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

Examples

{
	SharedPtr!long x = SharedPtr!long.make(1);

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

{
	SharedPtr!(shared long) x = SharedPtr!(shared long).make(1);

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

{
	shared SharedPtr!(long) x = SharedPtr!(shared long).make(1);

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

Meta