The OpenD Programming Language

rcarray

  1. auto rcarray(Range range)
  2. auto rcarray(Range range)
    rcarray
    (
    T = void
    Range
    )
    (
    Range range
    )
    if (
    is(T == void) &&
    &&
    is(Range == LightScopeOf!Range)
    &&
    !isArray!Range
    )
  3. RCArray!V rcarray(V[] values)
  4. RCArray!V rcarray(V[] values, bool deallocate)
  5. template rcarray(T)

Examples

RCArray!double a = rcarray!double(1.0, 2, 5, 3);
assert(a[0] == 1);
assert(a[$ - 1] == 3);

auto s = rcarray!char("hello!");
assert(s[0] == 'h');
assert(s[$ - 1] == '!');

alias rcstring = rcarray!(immutable char);
auto r = rcstring("string");
assert(r[0] == 's');
assert(r[$ - 1] == 'g');

With Input Ranges

import mir.algorithm.iteration: filter;
static immutable numbers = [3, 2, 5, 2, 3, 7, 3];
static immutable filtered = [5.0, 7];
auto result = numbers.filter!"a > 3".rcarray!(immutable double);
static assert(is(typeof(result) == RCArray!(immutable double)));
assert (result[] == filtered);

Meta