template<typename RESULT, template< qStroika_template_template_BWA(typename, typename)> class CACHE = LRUCache, typename... ARGS>
requires (ICache<CACHE<tuple<ARGS...>, RESULT>, tuple<ARGS...>, RESULT>)
class Stroika::Foundation::Cache::Memoizer< RESULT, CACHE, ARGS >
Cache the results of expensive computations transparently.
- See also
- https://en.wikipedia.org/wiki/Memoization
TODO: o
o
- Example Usage
unsigned int totalCallsCount{};
EXPECT_TRUE (memoizer (1, 1) == 2 and totalCallsCount == 1);
EXPECT_TRUE (memoizer (1, 1) == 2 and totalCallsCount == 1);
Memoizer memoizer = Cache::Factory::Memoizer::Make ([&totalCallsCount] (int a, int b) { totalCallsCount++; return a + b; });
Cache the results of expensive computations transparently.
- See also
- Factory::Memoizer::Make () for more simple to use examples.
- Note
- Memoizer works well with LRUCache, or TimedCache.
-
Thread-Safety Same as (worse case of) underlying CACHE template argument, and argument function. Since the function will typically be fully reentrant, this comes down to the re-entrancy of the argument Cache.
Definition at line 69 of file Memoizer.h.