empty_like

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

pure
empty_like
(
S
)
()

Parameters

slice S

n-dimensional slice to refer shape and element type

Return Value

Type: auto

new empty slice

Examples

auto s = empty!int(2, 3);
auto e = empty_like(s);

static assert(is(typeof(e) == typeof(s)));
assert(e.shape == s.shape);
s[0, 0] += 1;
assert(e != s);

Meta