memo_function.hpp
A function that memorizes previous results to speed up any repeated calls.
Note
Status: BETA
-
template<class T>
class memo_function - #include <memo_function.hpp>
Identical to std::function, but memorizes prior results (caches them) so that the function doesn’t have to process those results again. (note: Genetic version is undefinined; must have a function signature.)
-
template<class R, class ARG>
class memo_function<R(ARG)> - #include <memo_function.hpp>
The simplest form of a memoized function with a single argument that is used as the cache key (no need for more complex caching).
Public Types
-
using this_t = memo_function<R(ARG)>
Public Functions
-
inline memo_function()
-
template<typename T>
inline this_t &operator=(T &&arg) A universal copy/move for other combinations that work with std::function.
-
inline void Clear()
Clear out the cache.
-
inline operator bool() const
Identify if the memo_function has been set.
-
using this_t = memo_function<R(ARG)>
-
template<class R, class A1, class A2, class ...EXTRA>
class memo_function<R(A1, A2, EXTRA...)> - #include <memo_function.hpp>
Memoize functions for when we have more than one argument… we need to convert inputs to a tuple to make this work.
Public Types
Public Functions
-
memo_function(const memo_function&) = default
-
memo_function(memo_function&&) = default
-
inline void Clear()
-
inline operator bool() const
Public Static Functions
-
memo_function(const memo_function&) = default