1 #include "FunctionsAsTemplate.h"
9 namespace FunctionsAsTemplate
11 template <i64(*f
)(i64
)>
14 static std::map
<i64
, i64
> cache
;
15 auto i
= cache
.find(x
);
19 return cache
[x
] = f(x
);
26 return memoize
<fib
>(n
- 1) + memoize
<fib
>(n
- 2);
30 void FunctionsAsTemplate::tests()
33 cout
<< "fib(" << n
<< ") = " << fib(n
) << endl
;