Documentation Home >> Headers >> <jss/concurrent_map.hpp> Header >> jss::concurrent_map >> emplace member function

If there is no key-value pair associated with the specified key in a given jss::concurrent_map object, construct a new one from the specified key and data.

template<typename KT,typename DT>
std::pair<iterator,bool> emplace(KT && key,DT && data);

Effects:

Construct a new key-value pair for the specified key as value_type(std::forward<KT>(key),std::forward<DT>(data)). Insert that pair into the map if and only if there is no such entry already in the map after constructing the new object. If the new object is not inserted into the map then it is destroyed.

Returns:

A pair of an iterator and a bool. The iterator refers to either the newly-inserted object or the pre-existing object with the specified key, and the bool value is true if a new value was inserted, otherwise false.

Throws:

std::bad_alloc if memory for the new entry cannot be allocated. Any exception thrown by the construction of the new value_type object from key and data. Any exception thrown by the application of the Hasher or KeyEquals objects.

Synchronization:

emplace() may be called concurrently with any other member function of jss::concurrent_map on a given instance (except for the constructor and destructor) without external synchronization.

Header

#include <jss/concurrent_map.hpp>

See Also