Alias IntrusivePtr.WeakType

Weak pointer

struct IntrusivePtr
{
  // ...
  alias WeakType = IntrusivePtr!(_Type,true);
  // ...
}

IntrusivePtr.WeakType is a smart pointer that holds a non-owning ("weak") reference to an object that is managed by IntrusivePtr. It must be converted to IntrusivePtr in order to access the referenced object.

IntrusivePtr.WeakType models temporary ownership: when an object needs to be accessed only if it exists, and it may be deleted at any time by someone else, IntrusivePtr.WeakType is used to track the object, and it is converted to IntrusivePtr to assume temporary ownership. If the original IntrusivePtr is destroyed at this time, the object's lifetime is extended until the temporary IntrusivePtr is destroyed as well.

Another use for IntrusivePtr.WeakType is to break reference cycles formed by objects managed by IntrusivePtr. If such cycle is orphaned (i,e. there are no outside shared pointers into the cycle), the IntrusivePtr reference counts cannot reach zero and the memory is leaked. To prevent this, one of the pointers in the cycle can be made weak.