Insert a source range, shifting subsequent elements.

Synopsis

Declared in <bslalg_arrayprimitives.h>

template<
    class TARGET_TYPE,
    class FWD_ITER,
    class SENTINEL>
static
void
insert(
    TARGET_TYPE* toBegin,
    TARGET_TYPE* toEnd,
    FWD_ITER fromBegin,
    SENTINEL fromEnd,
    size_type numElements,
    bslma::Allocator* allocator);

Description

Insert, into the array at the specified toBegin location, the specified numElements from the range starting at the specified fromBegin iterators of the (template parameter) FWD_ITER type (or the (template parameter) SOURCE_TYPE *) and ending immediately before the specified fromEnd sentinels or iterators of the (template parameter) SENTINEL type (or the (template parameter) SOURCE_TYPE *), into the array of elements of the parameterized TARGET_TYPE starting at the specified toBegin address and ending immediately before the specified toEnd address, shifting the elements in the array by numElements positions towards larger addresses. The behavior is undefined unless the destination array contains numElements uninitialized elements after toEnd, numElements is the distance between fromBegin and fromEnd, and the input array and the destination array do not overlap. If a copy constructor or assignment operator for TARGET_TYPE throws an exception, then any elements created after toEnd are destroyed and the elements in the range [ toBegin, toEnd )] will have unspecified, but valid, values.

Parameters

Name

Description

toBegin

insertion position within the destination array

toEnd

end of the populated destination range

fromBegin

beginning of the source range to insert

fromEnd

end of the source range to insert

numElements

number of elements to insert from the source range

allocator

allocator used to supply memory if required

Created with MrDocs