Inserts a new element in the unordered_multimap container. This new element is constructed in place using args as the arguments for the element's constructor. position points to a location in the container suggested as a hint on where to start the search for its insertion point (the container may or may not use this suggestion to optimize the insertion operation).

A similar member function exists, insert, which either copies or moves an existing object into the container, and may also take a position hint.

Parameters

position

Position suggested as a hint for the insertion operation. This value may be used by the container to optimize the operation.
Member type const_iterator is a forward iterator type.

args

Arguments used to construct a new object of the mapped type for the inserted element.

Arguments forwarded to construct the new element (of type pair<const key_type, mapped_type>).
This can be one of:
- Two arguments: one for the key, the other for the mapped value.
- A single argument of a pair type with a value for the key as first member, and a value for the mapped value as second.
- piecewise_construct as first argument, and two additional arguments with tuples to be forwarded as arguments for the key value and for the mapped value respectivelly.
See pair::pair for more info.

Return value

The storage for the new element is allocated using allocator_traits<allocator_type>::construct(), which may throw exceptions on failure (for the default allocator, bad_alloc is thrown if the allocation request does not succeed).

Example

Complexity

Iterator validity

On most cases, all iterators in the container remain valid after the insertion. The only exception being when the growth of the container forces a rehash. In this case, all iterators in the container are invalidated.

A rehash is forced if the new container size after the insertion operation would increase above its capacity threshold (calculated as the container's bucket_count multiplied by its max_load_factor).