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"
32 concept IKey = same_as<T, NonKeyedKeySentinalType> or copyable<T>;
37 template <
typename KEY>
38 static constexpr bool IKeyedCache = not same_as<KEY, NonKeyedKeySentinalType>;
51 concept IValue = same_as<T, ValuelessSentinalType> or copyable<T>;
60 template <
typename VALUE>
72 template <
typename CACHE,
typename KEY,
typename VALUE>
75 (IKeyedCache<KEY> and ((IValuelessCache<VALUE> and
76 requires (CACHE c, KEY k) {
78 { c.Lookup (k) } -> convertible_to<optional<KEY>>;
79 { c.LookupValue (k, function<VALUE (KEY)>{}) } -> convertible_to<KEY>;
81 (not IValuelessCache<VALUE> and
82 requires (CACHE c, KEY k, VALUE v) {
84 { c.Lookup (k) } -> convertible_to<optional<VALUE>>;
85 { c.LookupValue (k, function<VALUE (KEY)>{}) } -> convertible_to<VALUE>;
88 or (not IKeyedCache<KEY> and
requires (CACHE c, VALUE v) {
90 { c.Lookup () } -> convertible_to<optional<VALUE>>;
91 { 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...