Go to the documentation of this file.
9 #ifndef EAGINE_MEMOIZED_HPP
10 #define EAGINE_MEMOIZED_HPP
21 template <
typename R,
typename... P>
22 class memoized<R(P...)> {
24 using T = std::tuple<P...>;
25 using E = std::pair<T, R>;
32 typename = std::enable_if_t<!std::is_same_v<std::decay_t<Func>, memoized>>>
34 : _func(std::forward<Func>(func)) {}
37 auto operator()(P... p,
const F& f) -> R {
39 auto i = _memo.find(t);
40 if(i == _memo.end()) {
41 i = _memo.insert(E(t, f(p..., *
this))).first;
46 auto operator()(P... p) -> R {
47 return _func(p..., *
this);
61 #endif // EAGINE_MEMOIZED_HPP
Common code is placed in this namespace.
Definition: eagine.hpp:21
basic_callable_ref< Sig, is_noexcept_function_v< Sig > > callable_ref
Alias for callable object references.
Definition: callable_ref.hpp:191