import mir.ndslice.allocation; auto a = slice!int(2, 3); auto b = [1, 2, 3, 4].sliced(2, 2); a[0..$, 0..$-1] = b; assert(a == [[1, 2, 0], [3, 4, 0]]); // fills both rows with b[0] a[0..$, 0..$-1] = b[0]; assert(a == [[1, 2, 0], [1, 2, 0]]); a[1, 0..$-1] = b[1]; assert(a[1] == [3, 4, 0]); a[1, 0..$-1][] = b[0]; assert(a[1] == [1, 2, 0]);
Left slice is packed
import mir.ndslice.topology : blocks, iota; import mir.ndslice.allocation : slice; auto a = slice!int(4, 4); a.blocks(2, 2)[] = iota!int(2, 2); assert(a == [[0, 0, 1, 1], [0, 0, 1, 1], [2, 2, 3, 3], [2, 2, 3, 3]]);
Both slices are packed
import mir.ndslice.topology : blocks, iota, pack; import mir.ndslice.allocation : slice; auto a = slice!int(4, 4); a.blocks(2, 2)[] = iota!int(2, 2, 2).pack!1; assert(a == [[0, 1, 2, 3], [0, 1, 2, 3], [4, 5, 6, 7], [4, 5, 6, 7]]);
Assignment of a value of Slice type to a fully defined slice.