RcPtr.useCount

Returns the number of different RcPtr instances

Returns the number of different RcPtr instances (this included) managing the current object or 0 if there is no managed object.

struct RcPtr
@property const scope nothrow @trusted @nogc
useCount
(
this This
)
()

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);

Meta