mir_slice.indexStride

Undocumented in source. Be warned that the author may not have intended to support it.
struct mir_slice(Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous, Labels_...)
package @safe scope const
@optmath
size_t
indexStride
(
size_t I
)
(
size_t[I] _indices
)
if (
0 < N_ &&
N_ < 255
&&
!(
kind_ == Canonical &&
N_ == 1
)
&&
Labels_.length <= N_
&&
isIterator!Iterator_
)

Examples

Creates a 2-dimentional slice with custom strides.

uint[8] array = [1, 2, 3, 4, 5, 6, 7, 8];
auto slice = Slice!(uint*, 2, Universal)([2, 2], [4, 1], array.ptr);

assert(&slice[0, 0] == &array[0]);
assert(&slice[0, 1] == &array[1]);
assert(&slice[1, 0] == &array[4]);
assert(&slice[1, 1] == &array[5]);
assert(slice == [[1, 2], [5, 6]]);

array[2] = 42;
assert(slice == [[1, 2], [5, 6]]);

array[1] = 99;
assert(slice == [[1, 99], [5, 6]]);

Meta