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.

  1. bool expandArray(T[] array, size_t delta)
  2. bool expandArray(T[] array, size_t delta, T init)
    struct TypedAllocator(PrimaryAllocator, Policies...)
    bool
    expandArray
    (
    T
    )
    (
    T[] array
    ,
    size_t delta
    ,
    auto ref T init
    )
  3. bool expandArray(T[] array, R range)

Parameters

T

element type of the array being created

array T[]

a reference to the array being grown

delta size_t

number of elements to add (upon success the new length of array is array.length + delta)

init T

element used for filling the array

Return Value

Type: bool

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.

Meta