like

Construct new slice having the same element type and shape to given slice.

pure
like
(
alias initializer
S
)
()

Parameters

initializer

template function(ElementType)(shape) that initializes slice

slice S

n-dimensional slice to refer shape and element type

Return Value

Type: auto

new initialized slice with Initializer alias

Examples

import mir.ndslice.topology : iota;
import mir.ndslice.slice : DeepElementType;

//  -------
// | 1 2 3 |
// | 4 5 6 |
//  -------
auto s = iota([2, 3], 1);
//  -------
// | 0 1 2 |
// | 3 4 5 |
//  -------
auto e = s.like!iota;

static assert(is(typeof(e) == typeof(s)));
assert(e.shape == s.shape);
assert(e != s);
alias S = DeepElementType!(typeof(s));
alias E = DeepElementType!(typeof(e));
static assert(is(S == E));

Meta