Function refCounted
Return a ref counted version of the given item.
Example
// note that destructor is called from the parameter to refCounted, so we
// must trigger only counting destruction of non-init instances of the
// struct.
size_t dtorcalled = 0;
struct S
{
int x;
@safe ~this() {if(x) dtorcalled++;}
@disable this(this);
}
{
auto destroyme = S(1) .refCounted;
auto dm2 = destroyme;
auto dm3 = destroyme;
}
assert(dtorcalled == 1);