View source code
Display the source code in std/array.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
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.
Function std.array.minimallyInitializedArray
Returns a new array of type T
allocated on the garbage collected heap.
auto minimallyInitializedArray(T, I...)
(
I sizes
) nothrow @trusted
if (isDynamicArray!T && allSatisfy!(isIntegral, I));
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
.
minimallyInitializedArray is nothrow
and weakly pure
.
Parameters
Name | Description |
---|---|
T | The type of the array elements |
sizes | The length dimension(s) of the resulting array |
Returns
An array of T
with I
dimensions.
Example
import std .algorithm .comparison : equal;
import std .range : repeat;
auto arr = minimallyInitializedArray!(int[])(42);
writeln(arr .length); // 42
// Elements aren't necessarily initialized to 0, so don't do this:
// assert(arr.equal(0.repeat(42)));
// If that is needed, initialize the array normally instead:
auto arr2 = new int[42];
assert(arr2 .equal(0 .repeat(42)));
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.