Heterogeneous cache indexed by entry ID.
More...
#include <helpers.hpp>
|
| | Cache ()=default |
| template<auto ID> |
| bool | is_set () const noexcept |
| template<auto ID, typename TYPE> |
| void | set (TYPE &&value) const |
| template<auto ID> |
| bool | invalidate () const noexcept |
| bool | invalidate () const noexcept |
| template<auto ID> |
| const type_for< ID > & | operator() (auto &&calculate_func) const |
| template<auto ID> |
| std::optional< type_for< ID > > | get () const |
| template<auto ID> |
| const type_for< ID > & | get_or_compute (auto &&calculate_func) const |
template<typename... ENTRIES>
class CECCO::details::Cache< ENTRIES >
Heterogeneous cache indexed by entry ID.
- Template Parameters
-
Each ID gets its own std::optional<T> slot in a std::tuple, so different IDs may share the same value type without ambiguity. Lookup is by compile-time ID; an unknown ID is a compile-time error.
- Warning
- Not thread-safe for concurrent writes. Use external synchronisation if multiple threads may call set(), invalidate(), or operator() simultaneously.
Usage_Example
cache.
set<0>(std::vector<int>{1, 2, 3});
auto& vec = cache.
get_or_compute<0>([] {
return std::vector<int>{4, 5, 6}; });
bool is_set() const noexcept
bool invalidate() const noexcept
const type_for< ID > & get_or_compute(auto &&calculate_func) const
void set(TYPE &&value) const
Cache entry specification.
Definition at line 408 of file helpers.hpp.
◆ Cache()
template<typename... ENTRIES>
◆ get()
template<typename... ENTRIES>
template<auto ID>
◆ get_or_compute()
template<typename... ENTRIES>
template<auto ID>
◆ invalidate() [1/2]
template<typename... ENTRIES>
◆ invalidate() [2/2]
template<typename... ENTRIES>
template<auto ID>
◆ is_set()
template<typename... ENTRIES>
template<auto ID>
◆ operator()()
template<typename... ENTRIES>
template<auto ID>
◆ set()
template<typename... ENTRIES>
template<auto ID, typename TYPE>
The documentation for this class was generated from the following file: