View source code
Display the source code in std/experimental/allocator/typed.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.experimental.allocator.typed.TypedAllocator.expandArray

Grows array by appending delta more elements. The needed memory is allocated using the same allocator that was used for the array type. The extra elements added are either default-initialized, filled with copies of init, or initialized with values fetched from range.

bool expandArray(T) (
  ref T[] array,
  size_t delta
);

bool expandArray(T) (
  T[] array,
  size_t delta,
  auto ref T init
);

bool expandArray(T, R) (
  ref T[] array,
  R range
)
if (isInputRange!R);

Parameters

NameDescription
T element type of the array being created
array a reference to the array being grown
delta number of elements to add (upon success the new length of array is array.length + delta)
init element used for filling the array
range range used for initializing the array elements

Returns

true upon success, false if memory could not be allocated. In the latter case array is left unaffected.

Throws

The first two overloads throw only if the used allocator's primitives do. The overloads that involve copy initialization deallocate memory and propagate the exception if the copy operation throws.

Authors

License