makeUninitSlice

Allocates an uninitialized array through a specified allocator and creates an n-dimensional slice over it. See also std.experimental.allocator.

@optmath
Slice!(T*, N)
makeUninitSlice
(
T
Allocator
size_t N
)
(
auto ref Allocator alloc
,
size_t[N] lengths...
)
if (
N
)

Parameters

alloc Allocator

allocator

lengths size_t[N]

list of lengths for each dimension

Return Value

Type: Slice!(T*, N)

a structure with fields array and slice

Examples

import std.experimental.allocator;
import std.experimental.allocator.mallocator;

auto sl = makeUninitSlice!int(Mallocator.instance, 2, 3, 4);
auto ar = sl.field;
assert(ar.ptr is sl.iterator);
assert(ar.length           == 24);
assert(sl.elementCount    == 24);

Mallocator.instance.dispose(ar);

Meta