mir_slice.opIndexAssign

Undocumented in source. Be warned that the author may not have intended to support it.
  1. void opIndexAssign(Slice!(RIterator, RN, rkind) value, Slices slices)
  2. void opIndexAssign(T[] value, Slices slices)
  3. void opIndexAssign(T concatenation, Slices slices)
  4. void opIndexAssign(T value, Slices slices)
  5. void opIndexAssign(DeepElement value, Slices slices)
    struct mir_slice(Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous, Labels_...)
    scope
    @optmath
    static if(isMutable!DeepElement)
    static if(!(!isNumeric!DeepElement))
    void
    opIndexAssign
    (
    Slices...
    )
    if ()
    if (
    0 < N_ &&
    N_ < 255
    &&
    !(
    kind_ == Canonical &&
    N_ == 1
    )
    &&
    Labels_.length <= N_
    &&
    isIterator!Iterator_
    )
  6. auto ref opIndexAssign(T value, size_t[N] _indices)
  7. auto ref opIndexAssign(DeepElement value, size_t[N] _indices)

Examples

import mir.ndslice.allocation;
auto a = slice!int(2, 3);

a[] = 9;
assert(a == [[9, 9, 9], [9, 9, 9]]);

a[0..$, 0..$-1] = 1;
assert(a == [[1, 1, 9], [1, 1, 9]]);

a[0..$, 0..$-1] = 2;
assert(a == [[2, 2, 9], [2, 2, 9]]);

a[1, 0..$-1] = 3;
//assert(a[1] == [3, 3, 9]);

a[1, 0..$-1] = 4;
//assert(a[1] == [4, 4, 9]);

a[1, 0..$-1][] = 5;

assert(a[1] == [5, 5, 9]);

Packed slices have the same behavior.

import mir.ndslice.allocation;
import mir.ndslice.topology : pack;
auto a = slice!int(2, 3).pack!1;

a[] = 9;
//assert(a == [[9, 9, 9], [9, 9, 9]]);

Meta