uninitializedFill

Initializes each element of range with value. Assumes that the elements of the range are uninitialized. This is of interest for structs that define copy constructors (for all other types, fill and uninitializedFill are equivalent).

void
uninitializedFill
(
Range
Value
)
(
Range range
,
Value value
)
if (
isInputRange!Range &&
&&
is(typeof(range.front = value))
)

Parameters

range Range

An input range that exposes references to its elements and has assignable elements

value Value

Assigned to each element of range

Examples

import core.stdc.stdlib : malloc, free;

auto s = (cast(int*) malloc(5 * int.sizeof))[0 .. 5];
uninitializedFill(s, 42);
assert(s == [ 42, 42, 42, 42, 42 ]);

scope(exit) free(s.ptr);

See Also

Meta