static class Foo{ private ControlBlock!int control; int i; this(int i)pure nothrow @safe @nogc{ this.i = i; } } static struct Bar{ private ControlBlock!int control; int i; this(int i)pure nothrow @safe @nogc{ this.i = i; } } { auto i = IntrusivePtr!Foo.make(42); assert(i.useCount == 1); Foo foo = i.get; auto i2 = intrusivePtr(foo); assert(i.useCount == 2); } { auto i = IntrusivePtr!Bar.make(42); assert(i.useCount == 1); Bar* bar = i.element; auto i2 = intrusivePtr(bar); assert(i.useCount == 2); }
Create IntrusivePtr instance from class reference Elm or struct pointer element Elm.
Elm was created by IntrusivePtr.make or IntrusivePtr.alloc.