The OpenD Programming Language

mir_slice.lightConst

  1. Slice!(LightConstOf!Iterator, N, kind, staticMap!(LightConstOf, Labels)) lightConst()
  2. Slice!(LightImmutableOf!Iterator, N, kind, staticMap!(LightImmutableOf, Labels)) lightConst()
    struct mir_slice(Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous, Labels_...)
    return scope immutable @property
    lightConst
    ()
    ()
    if (
    0 < N_ &&
    N_ < 255
    &&
    !(
    kind_ == Canonical &&
    N_ == 1
    )
    &&
    Labels_.length <= N_
    &&
    isIterator!Iterator_
    )

Return Value

Type: Slice!(LightImmutableOf!Iterator, N, kind, staticMap!(LightImmutableOf, Labels))

Mutable slice over const data.

Examples

import mir.algorithm.iteration: equal;

const Slice!(int*, 1) x = [1, 2].sliced;
auto y = x.lightConst;
// this._iterator is copied to the new slice (i.e. both point to the same underlying data)
assert(x._iterator == y._iterator);
assert(x.equal([1, 2]));
assert(y.equal([1, 2]));
// Outer const is moved to iteration type
static assert(is(typeof(y) == Slice!(const(int)*, 1)));
// meaning that y can be modified, even if its elements can't
y.popFront;
// even if x can't be modified
//x.popFront; //error

Meta