makeArray

Create an array of T with length elements using alloc. The array is either default-initialized, filled with copies of init, or initialized with values fetched from range.

  1. T[] makeArray(Allocator alloc, size_t length)
    version(HasDRuntime)
    T[]
    makeArray
    (
    T
    Allocator
    )
    (
    auto ref Allocator alloc
    ,
    size_t length
    )
  2. T[] makeArray(Allocator alloc, size_t length, T init)
  3. Unqual!(ElementEncodingType!R)[] makeArray(Allocator alloc, R range)
  4. T[] makeArray(Allocator alloc, R range)

Parameters

T

element type of the array being created

alloc Allocator

the allocator used for getting memory

length size_t

length of the newly created array

Return Value

Type: T[]

The newly-created array, or null if either length was 0 or allocation failed.

Throws

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

Meta