[#BloombergLP-bslalg-ArrayPrimitives-insert-0ad] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::xref:BloombergLP/bslalg/ArrayPrimitives.adoc[ArrayPrimitives]::insert :relfileprefix: ../../../ :mrdocs: `insert` overloads == Synopses Declared in `<bslalg_arrayprimitives.h>` Insert the specified `value` into the array of `allocator_traits<ALLOCATOR>::value_type` objects at the specified `toBegin` location, shifting forward the elements from `toBegin` to the specified `toEnd` location by one position. `value` is left in a valid but unspecified state. If a (copy or move) constructor or a (copy or move) assignment operator throws an exception, then any elements created after `toEnd` are destroyed and the elements in the range `[toBegin .. toEnd )]` are left in a valid but unspecified state. The behavior is undefined unless `toBegin` refers to sufficient space to hold at least `toEnd ‐ toBegin + 1` elements. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOCATOR> static void xref:BloombergLP/bslalg/ArrayPrimitives/insert-04.adoc[insert]( bsl::allocator_traits<ALLOCATOR>::pointer toBegin, bsl::allocator_traits<ALLOCATOR>::pointer toEnd, xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef<bsl::allocator_traits<ALLOCATOR>::value_type>] value, ALLOCATOR allocator); ---- [.small]#xref:BloombergLP/bslalg/ArrayPrimitives/insert-04.adoc[_» more..._]# Insert the specified `value` into the array of the (template parameter) type `TARGET_TYPE` at the specified `toBegin` address, shifting the elements from `toBegin` to the specified `toEnd` address by one position towards larger addresses. `value` is left in a valid but unspecified state. If a (copy or move) constructor or a (copy or move) assignment operator throws an exception, then any elements created after `toEnd` are destroyed and the elements in the range `[toBegin .. toEnd )]` are left in a valid but unspecified state. The behavior is undefined unless `toBegin` refers to sufficient space to hold at least `toEnd ‐ toBegin + 1` elements. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TARGET_TYPE> static void xref:BloombergLP/bslalg/ArrayPrimitives/insert-0d.adoc[insert]( TARGET_TYPE* toBegin, TARGET_TYPE* toEnd, xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef<TARGET_TYPE>] value, xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* allocator); ---- [.small]#xref:BloombergLP/bslalg/ArrayPrimitives/insert-0d.adoc[_» more..._]# Insert the specified `numElements` copies of the specified `value` into the array of type `allocator_traits<ALLOCATOR>::value_type` starting at the specified `toBegin` location, shifting forward the elements from `toBegin` to the specified `toEnd` location by `numElements` positions. If a (copy or move) constructor or a (copy or move) assignment operator throws an exception, any elements created after `toEnd` are destroyed and the elements in the range `[toBegin .. toEnd)]` are left in a valid but unspecified state. The behavior is undefined unless `toBegin` refers to space sufficient to hold at least `toEnd ‐ toBegin + numElements` elements. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOCATOR> static void xref:BloombergLP/bslalg/ArrayPrimitives/insert-09.adoc[insert]( bsl::allocator_traits<ALLOCATOR>::pointer toBegin, bsl::allocator_traits<ALLOCATOR>::pointer toEnd, bsl::allocator_traits<ALLOCATOR>::value_type const& value, xref:BloombergLP/bslalg/ArrayPrimitives/size_type.adoc[size_type] numElements, ALLOCATOR allocator); ---- [.small]#xref:BloombergLP/bslalg/ArrayPrimitives/insert-09.adoc[_» more..._]# Insert the specified `numElements` copies of the specified `value` into the array of (template parameter) `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 at least `numElements` uninitialized elements after `toEnd`. 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TARGET_TYPE> static void xref:BloombergLP/bslalg/ArrayPrimitives/insert-0ab.adoc[insert]( TARGET_TYPE* toBegin, TARGET_TYPE* toEnd, TARGET_TYPE const& value, xref:BloombergLP/bslalg/ArrayPrimitives/size_type.adoc[size_type] numElements, xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* allocator); ---- [.small]#xref:BloombergLP/bslalg/ArrayPrimitives/insert-0ab.adoc[_» more..._]# Same as the preceding `insert` overload, taking pointer iterators. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class ALLOCATOR, class SOURCE_TYPE> static void xref:BloombergLP/bslalg/ArrayPrimitives/insert-0e.adoc[insert]( bsl::allocator_traits<ALLOCATOR>::pointer toBegin, bsl::allocator_traits<ALLOCATOR>::pointer toEnd, SOURCE_TYPE* fromBegin, SOURCE_TYPE* fromEnd, xref:BloombergLP/bslalg/ArrayPrimitives/size_type.adoc[size_type] numElements, ALLOCATOR allocator); ---- [.small]#xref:BloombergLP/bslalg/ArrayPrimitives/insert-0e.adoc[_» more..._]# Same as the preceding overload, taking pointer iterators. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class TARGET_TYPE, class SOURCE_TYPE> static void xref:BloombergLP/bslalg/ArrayPrimitives/insert-0c.adoc[insert]( TARGET_TYPE* toBegin, TARGET_TYPE* toEnd, SOURCE_TYPE* fromBegin, SOURCE_TYPE* fromEnd, xref:BloombergLP/bslalg/ArrayPrimitives/size_type.adoc[size_type] numElements, xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* allocator); ---- [.small]#xref:BloombergLP/bslalg/ArrayPrimitives/insert-0c.adoc[_» more..._]# TBD: improve comment 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class ALLOCATOR, class FWD_ITER, class SENTINEL> static void xref:BloombergLP/bslalg/ArrayPrimitives/insert-0f.adoc[insert]( bsl::allocator_traits<ALLOCATOR>::pointer toBegin, bsl::allocator_traits<ALLOCATOR>::pointer toEnd, FWD_ITER fromBegin, SENTINEL fromEnd, xref:BloombergLP/bslalg/ArrayPrimitives/size_type.adoc[size_type] numElements, ALLOCATOR allocator); ---- [.small]#xref:BloombergLP/bslalg/ArrayPrimitives/insert-0f.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class TARGET_TYPE, class FWD_ITER, class SENTINEL> static void xref:BloombergLP/bslalg/ArrayPrimitives/insert-06.adoc[insert]( TARGET_TYPE* toBegin, TARGET_TYPE* toEnd, FWD_ITER fromBegin, SENTINEL fromEnd, xref:BloombergLP/bslalg/ArrayPrimitives/size_type.adoc[size_type] numElements, xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* allocator); ---- [.small]#xref:BloombergLP/bslalg/ArrayPrimitives/insert-06.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#