Function first

Return RcPtr pointing to first element of dynamic array managed by rc pointer ptr.

auto first(Ptr) (
  scope ref Ptr ptr
) @trusted
if (isRcPtr!Ptr && is(Ptr.ElementType : T[], T));

auto first(Ptr) (
  scope Ptr ptr
) @trusted
if (isRcPtr!Ptr && is(Ptr.ElementType : T[], T));

Example

//copy
{
    auto x = RcPtr!(long[]).make(10, -1);
    assert(x.length == 10);

    auto y = first(x);
    static assert(is(typeof(y) == RcPtr!long));
    assert(*y == -1);
    assert(x.useCount == 2);
}

{
    auto x = RcPtr!(long[10]).make(-1);
    assert(x.get.length == 10);

    auto y = first(x);
    static assert(is(typeof(y) == RcPtr!long));
    assert(*y == -1);
    assert(x.useCount == 2);
}

//move
import core.lifetime : move;
{
    auto x = RcPtr!(long[]).make(10, -1);
    assert(x.length == 10);

    auto y = first(x.move);
    static assert(is(typeof(y) == RcPtr!long));
    assert(*y == -1);
}

{
    auto x = RcPtr!(long[10]).make(-1);
    assert(x.get.length == 10);

    auto y = first(x.move);
    static assert(is(typeof(y) == RcPtr!long));
    assert(*y == -1);
}