{
SharedPtr!long x = SharedPtr!long.make(123);
assert(*x.ptr == 123);
x.get = 321;
assert(*x.ptr == 321);
const y = x;
assert(*y.ptr == 321);
assert(*x.ptr == 321);
static assert(is(typeof(y.ptr) == const(long)*));
}
{
auto x = SharedPtr!(long[]).make(6, 42);
assert(*x.ptr == 42);
static assert(is(typeof(x.ptr) == long*));
}
{
auto s = SharedPtr!long.make(42);
const w = s.weak;
assert(*w.ptr == 42);
s = null;
assert(w.ptr is null);
}
{
auto s = SharedPtr!long.make(42);
auto w = s.weak;
scope const p = w.ptr;
s = null;
assert(w.ptr is null);
assert(p !is null); //p is dangling pointer!
}
Get pointer to managed object of ElementType or reference if ElementType is reference type (class or interface) or pointer to first dynamic array element.
If this is weak expired pointer then return null.
Doesn't increment useCount, is inherently unsafe.