Report a bug
If you spot a problem with this page, click here to create a Github issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.shared_ptr

Thread-safe reference-counted shared pointers

.
struct mir_shared_ptr(T, bool cppSupport = .cppSupport!T) if (!is(T == class) && !is(T == interface));

alias SharedPtr = mir_shared_ptr(T, bool cppSupport = .cppSupport!T) if (!is(T == class) && !is(T == interface));

template shared_ptr(T)
Thread safe reference counting array.
__xdtor if any is used to destruct objects.
The implementation never adds roots into the GC.
Examples:
auto a = shared_ptr!double(10);
auto b = a;
assert(*b == 10);
*b = 100;
assert(*a == 100);
pure nothrow @nogc ref scope @trusted auto opAssign(typeof(null)) return;
pure nothrow @nogc ref scope @trusted auto opAssign(Q)(return scope const mir_shared_ptr!Q rhs)
if (isImplicitlyConvertible!(T*, Q*));

pure nothrow @nogc ref scope @trusted auto opAssign(Q)(return ref scope const mir_shared_ptr!Q rhs)
if (isImplicitlyConvertible!(T*, Q*));
this(typeof(null));
const pure nothrow @nogc @property scope @trusted size_t _counter();
const bool opCast(C : bool)();
pure nothrow @nogc mir_shared_ptr!Q opCast(C : mir_shared_ptr!Q, Q)()
if (isImplicitlyConvertible!(T*, Q*));

const pure nothrow @nogc mir_shared_ptr!Q opCast(C : mir_shared_ptr!Q, Q)()
if (isImplicitlyConvertible!(const(T)*, Q*));

immutable pure nothrow @nogc mir_shared_ptr!Q opCast(C : mir_shared_ptr!Q, Q)()
if (isImplicitlyConvertible!(immutable(T)*, Q*));
pure nothrow @nogc @property scope @safe bool opEquals(typeof(null));

pure nothrow @nogc @property scope @safe bool opEquals(Y)(auto ref scope const mir_shared_ptr!Y rhs);

pure nothrow @nogc @property scope @safe bool opEquals(Y)(scope const Y* rhs);
pure nothrow @nogc @property scope @safe sizediff_t opCmp(Y)(auto ref scope const mir_shared_ptr!Y rhs);

pure nothrow @nogc @property scope @safe sizediff_t opCmp(Y)(scope const Y* rhs);
inout ref inout(T) _get_value();

template opUnary(string op : "*")
const nothrow @nogc @property scope @trusted mir_shared_ptr!(const(T)) lightConst()() return;

immutable nothrow @nogc @property scope @trusted mir_shared_ptr!(immutable(T)) lightImmutable()() return;