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

Construct a new key-value pair from the specified key and data. If there is no key-value pair associated with the specified key in a given jss::concurrent_map object, insert the new one, otherwise replace the existing entry with the new one.

template<typename KT,typename DT>
void insert_or_replace(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, replacing any existing entry with the same key. If an entry is replaced then the old entry is destroyed when there is no longer any accesses to the map object that could reference it.

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:

insert_or_replace() 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