public member function
<unordered_set>

std::unordered_multiset::emplace_hint

template <class... Args>
iterator emplace_hint ( const_iterator position, Args&&... args );
Construct and insert element with hint
Inserts a new element in the unordered_multiset. 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).

This effectively increases the container size by one.

A similar member function exists, insert, which either copies or moves existing objects 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 passed to the constructor of the a new element to be inserted.

Return value

An iterator to the newly inserted element.

Member type iterator is a forward iterator type.

All iterators in an unordered_multiset have const access to the elements: Elements can be inserted or removed, but not modified while in the container.

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

No example yet. See unordered_multiset::emplace's example.

Complexity

Average case: constant.
Worst case: linear in container size.
May trigger a rehash (not included).

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).

References remain valid in all cases, even after a rehash.

See also

  • 9281021542 2018-02-20
  • 632231541 2018-02-20
  • 9751491540 2018-02-20
  • 8333621539 2018-02-20
  • 995001538 2018-02-20
  • 6477441537 2018-02-20
  • 511981536 2018-02-19
  • 2072881535 2018-02-19
  • 6024461534 2018-02-19
  • 7594061533 2018-02-19
  • 9311341532 2018-02-19
  • 4928331531 2018-02-19
  • 38561530 2018-02-19
  • 7776611529 2018-02-19
  • 3038041528 2018-02-19
  • 9566341527 2018-02-19
  • 3936031526 2018-02-19
  • 9531111525 2018-02-19
  • 291211524 2018-02-19
  • 8962001523 2018-02-19