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.uninitializedArray
Returns a new array of type T
allocated on the garbage collected heap
without initializing its elements. This can be a useful optimization if every
element will be immediately initialized. T
may be a multidimensional
array. In this case sizes may be specified for any number of dimensions from 0
to the number in T
.
auto uninitializedArray(T, I...)
(
I sizes
) nothrow @system
if (isDynamicArray!T && allSatisfy!(isIntegral, I) && hasIndirections!(ElementEncodingType!T));
auto uninitializedArray(T, I...)
(
I sizes
) nothrow @trusted
if (isDynamicArray!T && allSatisfy!(isIntegral, I) && !hasIndirections!(ElementEncodingType!T));
uninitializedArray is nothrow
and weakly pure
.
uninitializedArray is @system
if the uninitialized element type has pointers.
Parameters
Name | Description |
---|---|
T | The type of the resulting array elements |
sizes | The length dimension(s) of the resulting array |
Returns
An array of T
with I
dimensions.
Example
double[] arr = uninitializedArray!(double[])(100);
writeln(arr .length); // 100
double[][] matrix = uninitializedArray!(double[][])(42, 31);
writeln(matrix .length); // 42
writeln(matrix[0] .length); // 31
char*[] ptrs = uninitializedArray!(char*[])(100);
writeln(ptrs .length); // 100
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.