Cbeam
Loading...
Searching...
No Matches
cbeam/container/stable_interprocess_map.hpp

Updates an existing entry in the map or inserts a new one if the key does not exist.

Updates an existing entry in the map or inserts a new one if the key does not exist.This method abstracts the common pattern of checking for an existing key, updating its value if present, or inserting a new key-value pair if the key is not found. The method handles locking, deserialization, and serialization of the map internally.

Parameters
keyThe key to update or insert.
updaterA function that updates the value associated with the key. It takes a reference to the value type.
default_valueThe default value to insert if the key is not found in the map.
stable_interprocess_map<int, std::string> myMap("my_shared_memory", 1024);
myMap.update_or_insert(42, [](std::string& value) { value += " updated"; }, "default value");
Provides a type-safe, interprocess map with stable serialization.
Definition stable_interprocess_map.hpp:59