Fill an uninitialized array with copies of a value.

Synopsis

Declared in <bslalg_arrayprimitives.h>

template<class TARGET_TYPE>
static
void
uninitializedFillN(
    TARGET_TYPE* begin,
    size_type numElements,
    TARGET_TYPE const& value,
    bslma::Allocator* allocator);

Description

Construct copies of the specified value of the parameterized type TARGET_TYPE into the uninitialized array containing the specified numElements starting at the specified begin address. If the (template parameter) ALLOCATOR type is derived from bslma::Allocator and TARGET_TYPE supports bslma allocators, then the specified allocator is passed to each invocation of the TARGET_TYPE copy constructor. The behavior is undefined unless the output array contains at least numElements uninitialized elements after begin. If a TARGET_TYPE constructor throws an exception during the operation, then the destructor is called on any newly‐constructed elements, leaving the output array in an uninitialized state. Note that the argument order was chosen to maintain compatibility with the existing bslalg.

Parameters

Name

Description

begin

beginning of the uninitialized destination range

numElements

number of copies of value to construct

value

value copied into each constructed element

allocator

allocator passed to element constructors when applicable

Created with MrDocs