The OpenD Programming Language

asKindOf

Converts a slice to user provided kind.

Contiguous slices can be converted to any kind. Canonical slices can't be converted to contiguous slices. Universal slices can be converted only to the same kind.

template asKindOf(SliceKind kind)
static if(kind == Contiguous)
asKindOf
(
Iterator
size_t N
Labels...
)
(
Slice!(Iterator, N, Contiguous, Labels) slice
)

Examples

Universal

import mir.ndslice.slice: Universal;
auto slice = iota(2, 3).asKindOf!Universal;
assert(slice == [[0, 1, 2], [3, 4, 5]]);
assert(slice._lengths == [2, 3]);
assert(slice._strides == [3, 1]);

Canonical

import mir.ndslice.slice: Canonical;
auto slice = iota(2, 3).asKindOf!Canonical;
assert(slice == [[0, 1, 2], [3, 4, 5]]);
assert(slice._lengths == [2, 3]);
assert(slice._strides == [3]);

Contiguous

import mir.ndslice.slice: Contiguous;
auto slice = iota(2, 3).asKindOf!Contiguous;
assert(slice == [[0, 1, 2], [3, 4, 5]]);
assert(slice._lengths == [2, 3]);
assert(slice._strides == []);

See Also

Meta