BloombergLP::bslalg::ArrayPrimitives::insert

Insert a source range, shifting subsequent elements.

Synopsis

Declared in <bslalg_arrayprimitives.h>

template<
    class ALLOCATOR,
    class FWD_ITER,
    class SENTINEL>
static
void
insert(
    bsl::allocator_traits<ALLOCATOR>::pointer toBegin,
    bsl::allocator_traits<ALLOCATOR>::pointer toEnd,
    FWD_ITER fromBegin,
    SENTINEL fromEnd,
    size_type numElements,
    ALLOCATOR allocator);

Description

Insert the specified numElements from the range starting at the specified fromBegin of (template parameter) FWD_ITER type (or template parameter SOURCE_TYPE *) and ending immediately before the specified fromEnd sentinels or iterators of (template parameter) SENTINEL type (or template parameter SOURCE_TYPE *), into the array of elements of type given by the allocator_traits class template for (template parameter) ALLOCATOR, starting at the specified toBegin address, shifting forward the elements in the array by numElements positions. 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 throws an exception, then any elements created after toEnd are destroyed and the elements in the range [ toBegin, toEnd )] will have valid but unspecified values.

Parameters

NameDescription
toBegininsertion position within the destination array
toEndend of the populated destination range
fromBeginbeginning of the source range to insert
fromEndend of the source range to insert
numElementsnumber of elements to insert from the source range
allocatorallocator used to supply memory if required