static struct Foo{ ControlBlock!(int, int) c; int i; this(int i)pure nothrow @safe @nogc{ this.i = i; } } { auto x = IntrusivePtr!(shared Foo).make(123); assert(x.useCount == 1); shared s1 = share(x); assert(x.useCount == 2); import core.lifetime : move; shared s2 = share(x.move); assert(x == null); assert(s2.useCount == 2); assert(s2.load.get.i == 123); } { auto x = IntrusivePtr!(Foo).make(123); assert(x.useCount == 1); ///error `shared IntrusivePtr` need shared `ControlType` and shared `ElementType`. //shared s1 = share(x); }
Return shared IntrusivePtr pointing to same managed object like parameter ptr.
Type of parameter ptr must be IntrusivePtr with shared(ControlType) and shared/immutable ElementType .