Function RcPtr.useCount
Returns the number of different RcPtr
instances
ControlType .Shared useCount(This)() const nothrow @nogc @property scope @trusted;
Returns the number of different RcPtr
instances (this
included) managing the current object or 0
if there is no managed object.
Examples
RcPtr!long x = null;
assert(x .useCount == 0);
x = RcPtr!long .make(123);
assert(x .useCount == 1);
auto y = x;
assert(x .useCount == 2);
auto w1 = x .weak; //weak ptr
assert(x .useCount == 2);
RcPtr!long .WeakType w2 = x; //weak ptr
assert(x .useCount == 2);
y = null;
assert(x .useCount == 1);
x = null;
assert(x .useCount == 0);
assert(w1 .useCount == 0);