import mir.ndslice.allocation; auto a = slice!int(2, 3); auto b = [[1, 2], [3, 4]]; a[] = [[1, 2, 3], [4, 5, 6]]; assert(a == [[1, 2, 3], [4, 5, 6]]); a[0..$, 0..$-1] = [[1, 2], [3, 4]]; assert(a == [[1, 2, 3], [3, 4, 6]]); a[0..$, 0..$-1] = [1, 2]; assert(a == [[1, 2, 3], [1, 2, 6]]); a[1, 0..$-1] = [3, 4]; assert(a[1] == [3, 4, 6]); a[1, 0..$-1][] = [3, 4]; assert(a[1] == [3, 4, 6]);
Packed slices
import mir.ndslice.allocation : slice; import mir.ndslice.topology : blocks; auto a = slice!int(4, 4); a.blocks(2, 2)[] = [[0, 1], [2, 3]]; assert(a == [[0, 0, 1, 1], [0, 0, 1, 1], [2, 2, 3, 3], [2, 2, 3, 3]]);
Assignment of a regular multidimensional array to a fully defined slice.