SharedPtr.this

Constructs a SharedPtr which shares ownership of the object managed by rhs and pointing to element.

The aliasing constructor: constructs a SharedPtr which shares ownership information with the initial value of rhs, but holds an unrelated and unmanaged pointer ptr. If this SharedPtr is the last of the group to go out of scope, it will call the stored deleter for the object originally managed by rhs. However, calling get() or ptr() on this SharedPtr will always return a copy of element. It is the responsibility of the programmer to make sure that this ptr remains valid as long as this SharedPtr exists, such as in the typical use cases where element is a member of the object managed by rhs or is an alias (e.g., downcast) of rhs.get().

Examples

static struct Foo{
	int i;
	double d;
}
SharedPtr!Foo foo = SharedPtr!Foo.make(42, 3.14);

auto x = SharedPtr!double(foo, &foo.d);
assert(foo.useCount == 2);
assert(foo.get == 3.14);

Meta