42 using mapped_type = value_type;
43 using reference = mapped_type&;
44 using const_reference =
const mapped_type&;
45 using pointer = mapped_type*;
65 *
this = std::move(other);
72 template<
typename mapped_type_new>
inline auto emplace(mapped_type_new&&
object) {
74 return cacheMap.emplace(
makeUnique<std::remove_cvref_t<mapped_type_new>>(std::forward<mapped_type_new>(
object)));
81 template<
typename mapped_type_new>
inline reference
operator[](mapped_type_new&& key) {
84 cacheMap.emplace(makeUnique<mapped_type>());
93 template<
typename mapped_type_new>
inline bool contains(mapped_type_new&& key) {
95 return cacheMap.contains(std::forward<mapped_type_new>(key));
101 template<
typename mapped_type_new>
inline void erase(mapped_type_new&& key) {
103 cacheMap.erase(std::forward<mapped_type_new>(key));
A template class representing an object cache.
auto begin()
Get an iterator to the beginning of the cache.
object_cache()
Default constructor for the object_cache class.
object_cache(object_cache &&other) noexcept
Move constructor for the object_cache class.
auto emplace(mapped_type_new &&object)
Add an object to the cache.
auto end()
Get an iterator to the end of the cache.
unordered_set< unique_ptr< mapped_type > > cacheMap
The underlying container for storing objects.
std::shared_mutex cacheMutex
Mutex for ensuring thread-safe access to the cache.
uint64_t count()
Get the number of objects currently in the cache.
~object_cache()
Destructor for the object_cache class.
void erase(mapped_type_new &&key)
Remove an object from the cache using a key.
object_cache & operator=(object_cache &&other) noexcept
Move assignment operator for the object_cache class.
bool contains(mapped_type_new &&key)
Check if the cache contains an object with a given key.
reference operator[](mapped_type_new &&key)
Access an object in the cache using a key.
unique_ptr< value_type, deleter > makeUnique(arg_types &&... args)
Helper function to create a unique_ptr for a non-array object.
The main namespace for the forward-facing interfaces.