static struct Foo{ ControlBlock!(int, int) c; int i; alias i this; this(int i)pure nothrow @safe @nogc{ this.i = i; } } import std.conv; IntrusivePtr!Foo x = IntrusivePtr!Foo.make(123); assert(x.useCount == 1 ); auto y = cast(IntrusivePtr!(const Foo))x; //debug assert(x.useCount == 2, x.useCount.to!string); assert(x.useCount == 2); auto z = cast(const IntrusivePtr!Foo)x; assert(x.useCount == 3); auto u = cast(const IntrusivePtr!(const Foo))x; assert(x.useCount == 4);
Cast this to different type To when isIntrusivePtr!To.
BUG: qualfied variable of struct with dtor cannot be inside other struct (generated dtor will use opCast to mutable before dtor call ). opCast is renamed to opCastImpl