View source code Display the source code in std/array.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

Function std.array.minimallyInitializedArray

Returns a new array of type T allocated on the garbage collected heap.

Partial initialization is done for types with indirections, for preservation of memory safety. Note that elements will only be initialized to 0, but not necessarily the element type's .init.

minimallyInitializedArray is nothrow and weakly pure.

Prototype

auto minimallyInitializedArray(T, I...)(
  I sizes
) nothrow @trusted
if (isDynamicArray!T && allSatisfy!(isIntegral, I));

Example

int[] a = [ 10, 11, 12, 13, 14 ];
int[] b = a[1 .. 3];
assert(overlap(a, b) == [ 11, 12 ]);
b = b.dup;
// overlap disappears even though the content is the same
assert(overlap(a, b).empty);

Authors

Andrei Alexandrescu and Jonathan M Davis

License

Boost License 1.0.

Comments