initializeAll

Initializes all elements of range with their .init value. Assumes that the elements of the range are uninitialized.

This function is unavailable if T is a struct and T.this() is annotated with @disable.

  1. void initializeAll(Range range)
  2. void initializeAll(Range range)
    void
    initializeAll
    (
    Range
    )
    (
    Range range
    )
    if (
    is(Range == char[]) ||
    is(Range == wchar[])
    )

Parameters

range Range

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

Examples

import core.stdc.stdlib : malloc, free;

struct S
{
    int a = 10;
}

auto s = (cast(S*) malloc(5 * S.sizeof))[0 .. 5];
initializeAll(s);
assert(s == [S(10), S(10), S(10), S(10), S(10)]);

scope(exit) free(s.ptr);

See Also

Meta