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


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.


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.


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.


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.


#include <jss/concurrent_map.hpp>

See Also