The OpenD Programming Language

toRCPtrAt

  1. RCPtr!F toRCPtrAt(RCArray!F array, size_t index)
    @trusted
    toRCPtrAt
    (
    F
    )
    (
    return RCArray!F array
    ,
    size_t index
    )
    if (
    !is(R == class) &&
    !is(R == interface)
    )
  2. RCPtr!F toRCPtrAt(Slice!(RCI!F) array, size_t index)

Return Value

Type: RCPtr!F

shared pointer constructed with the array's context and the value points to array[index].

The function has zero computation cost.

Examples

struct S { double e; }

auto a = RCArray!S(10);
a[3].e = 4;

auto s = a.toRCPtrAt(3);

assert(s._counter == 2);
assert(s.e == 4);
struct S { double e; }

auto a = RCArray!S(10).asSlice[5 .. $];
a[3].e = 4;

auto s = a.toRCPtrAt(3);

assert(s._counter == 2);
assert(s.e == 4);

Meta