Inserts an element constructed in place (no copy or move operations are performed), with a placement hint.

template<class... Args>
   iterator emplace_hint(
      const_iterator where,
      Args&&... args);




The arguments forwarded to construct an element to be inserted into the unordered_map unless the unordered_map already contains that element or, more generally, unless it already contains an element whose key is equivalently ordered.


A hint regarding the place to start searching for the correct point of insertion.

An iterator to the newly inserted element.

If the insertion failed because the element already exists, returns an iterator to the existing element.

No references are invalidated by this function.

During the insertion, if an exception is thrown but does not occur in the container's hash function, the container is not modified. If the exception is thrown in the hash function, the result is undefined.

The value_type of an element is a pair, so that the value of an element will be an ordered pair with the first component equal to the key value and the second component equal to the data value of the element.

For a code example, see map::emplace_hint.

Header: <unordered_map>

Namespace: std

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft