Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
array::emplace

Insert a constructed element in-place.

Synopsis
template<
    class Arg>
iterator
emplace(
    const_iterator pos,
    Arg&& arg);
Description

Inserts a new element into the container directly before pos. The element is constructed using placement-new with the parameter std::forward<Arg>(arg). If capacity() < size() + 1, a reallocation occurs first, and all iterators and references are invalidated. Otherwise, only the iterators and references from the insertion point forward are invalidated. All past-the-end iterators are also invalidated.

Complexity

Constant plus linear in std::distance(pos, end()).

Exception Safety

Strong guarantee. Calls to memory_resource::allocate may throw.

Parameters

Name

Description

pos

Iterator before which the element will be inserted. This may be the end() iterator.

arg

The argument to forward to the value constructor.

Return Value

An iterator to the inserted element


PrevUpHomeNext