CelestialCalendar 1.0.0 · unreleased development @ 67a7c4c79a4a4a6aa7e703c9e6f0039ae34bee82
Loading...
Searching...
No Matches
cache.hpp File Reference
#include <mutex>
#include <tuple>
#include <memory>
#include <cstddef>
#include <utility>
#include <concepts>
#include <functional>
#include <type_traits>
#include <unordered_map>
#include "hash.hpp"

Classes

struct  util::cache::TupleHash< Args >

Namespaces

namespace  util
namespace  util::cache

Concepts

concept  util::cache::CacheKeyElement
 What one element of a cache key must support: equality, hashing, and being copyable — the key is copied into a tuple and again into the map. Element-wise on purpose: TupleHash's operator() takes any tuple and fails inside its body, so constraining it would constrain nothing.
concept  util::cache::FunctionConvertible
 Checks if a type can be converted to std::function.

Functions

template<typename RetType, typename... Args>
requires std::is_object_v<RetType> and std::copy_constructible<RetType> and (... and CacheKeyElement<std::decay_t<Args>>)
auto util::cache::make_cached (const std::function< RetType(Args...)> &func)
 A wrapper that caches the result of a function.
auto util::cache::cache_func (const FunctionConvertible auto &func)
 A wrapper that caches the result of a function.