Alias RcPtr.store

Stores the non shared RcPtr parameter ptr to this.

struct RcPtr
{
  // ...
  alias store = opAssign;
  // ...
}

If this is shared then operation is atomic or guarded by mutex.

Template parameter order has type core.atomic.MemoryOrder.

Examples

//null store:
{
    shared x = RcPtr!(shared long).make(123);
    assert(x.load.get == 123);

    x.store(null);
    assert(x.useCount == 0);
    assert(x.load == null);
}

//rvalue store:
{
    shared x = RcPtr!(shared long).make(123);
    assert(x.load.get == 123);

    x.store(RcPtr!(shared long).make(42));
    assert(x.load.get == 42);
}

//lvalue store:
{
    shared x = RcPtr!(shared long).make(123);
    auto y = RcPtr!(shared long).make(42);

    assert(x.load.get == 123);
    assert(y.load.get == 42);

    x.store(y);
    assert(x.load.get == 42);
    assert(x.useCount == 2);
}