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.

  1. auto asKindOf(Slice!(Iterator, N, Contiguous, Labels) slice)
    template asKindOf(SliceKind kind)
    @optmath
    static if(kind == Contiguous)
    asKindOf
    (
    Iterator
    size_t N
    Labels...
    )
    (
    Slice!(Iterator, N, Contiguous, Labels) slice
    )
  2. alias asKindOf = canonical
  3. alias asKindOf = universal

Members

Aliases

asKindOf
alias asKindOf = universal
Undocumented in source.
asKindOf
alias asKindOf = canonical
Undocumented in source.

Functions

asKindOf
auto asKindOf(Slice!(Iterator, N, Contiguous, Labels) slice)
Undocumented in source. Be warned that the author may not have intended to support it.

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