Function IntrusivePtr.weakCount
Returns the number of different IntrusivePtr
instances
ControlType .Weak weakCount(This)() const nothrow @nogc @property scope @safe;
Returns the number of different IntrusivePtr
instances (this
included) managing the current object or 0
if there is no managed object.
Examples
static struct Foo{
ControlBlock!(int, int) c;
int i;
this(int i)pure nothrow @safe @nogc{
this .i = i;
}
}
IntrusivePtr!Foo x = null;
assert(x .useCount == 0);
assert(x .weakCount == 0);
x = IntrusivePtr!Foo .make(123);
assert(x .useCount == 1);
assert(x .weakCount == 0);
auto w = x .weak();
assert(x .useCount == 1);
assert(x .weakCount == 1);