4#ifndef _Stroika_Foundation_Cache_Common_h_
5#define _Stroika_Foundation_Cache_Common_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
13#include "Stroika/Foundation/Common/Common.h"
14#include "Stroika/Foundation/Common/Concepts.h"
35 concept IKey = same_as<T, NonKeyedKeySentinalType> or copyable<T>;
40 template <
typename KEY>
41 static constexpr bool IKeyedCache = not same_as<KEY, NonKeyedKeySentinalType>;
54 concept IValue = same_as<T, ValuelessSentinalType> or copyable<T>;
63 template <
typename VALUE>
75 template <
typename CACHE,
typename KEY,
typename VALUE>
78 (IKeyedCache<KEY> and ((IValuelessCache<VALUE> and
79 requires (CACHE c, KEY k) {
81 { c.Lookup (k) } -> convertible_to<optional<KEY>>;
82 { c.LookupValue (k, function<VALUE (KEY)>{}) } -> convertible_to<KEY>;
84 (not IValuelessCache<VALUE> and
85 requires (CACHE c, KEY k, VALUE v) {
87 { c.Lookup (k) } -> convertible_to<optional<VALUE>>;
88 { c.LookupValue (k, function<VALUE (KEY)>{}) } -> convertible_to<VALUE>;
91 or (not IKeyedCache<KEY> and
requires (CACHE c, VALUE v) {
93 { c.Lookup () } -> convertible_to<optional<VALUE>>;
94 { c.LookupValue (function<VALUE ()>{}) } -> convertible_to<VALUE>;
Check if the argument CACHE is a valid 'stroika cache' class, following its api.
A Key is any copyable value (or the sentinal type void - indicating a keyless - single valued - cache...
Any copyable type can use used as the value, or the special sentinal type - ValuelessSentinalType,...
static constexpr bool IKeyedCache
Does this cache have a KEY type (overwhelming YES, but sometimes handy to have 'singleton' cache,...
void NonKeyedKeySentinalType
This sentinal value can be used as the KEY type for a Cache to indicate it is un-keyed,...
static constexpr bool IValuelessCache
Some caches (rare) only support a KEY, with no associated value (the value is stored INSIDE the key i...
void ValuelessSentinalType
This sentinal value can be used as the VALUE type for a Cache to indicate it just stores ONLY the KEY...