Memoization is very useful technique for developing algorithms. Python3 has native support for memoization and here is how it is used.
Similar feature can be implemeted in c++ . Here is an example on how to use.
originaly defined uint64_t fib(int n) has to be wrapped in macro that takes 3 parameters. return_type, func_name and arguments.
so it becomes MEMOIZATION(uint64_t, fib,(int n)) From user’s perspective it looks similar to python’s version.
Here is full implementation of macro MEMOIZATION, Memo class and helper function. This implementation is not same as lru_cache
where old items in cache are discarded once limit is reached.