C++ Unordered_set Library - emplace_hint


Advertisements

Description

It inserts a new element in the unordered_set if its value is unique. This new element is constructed in place using args as the arguments for the element's constructor.

Declaration

Following is the declaration for std::unordered_set::emplace_hint.

C++11

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

Parameters

  • position − It indicates about position.

  • args − These arguments passed to the constructor.

Return value

It returns if the insertion takes place (because no other element existed with the same value), the function returns an iterator to the inserted element.

Exceptions

Exception is thrown if any element comparison object throws exception.

Please note that invalid arguments cause undefined behavior.

Time complexity

constant time.

unordered_set.htm
Advertisements