Pure functions have an interesting property. For the same input values, they return the same outputs. This makes them equivalent to a big table of values with an output value corresponding to every combination of values for the input arguments. Sometimes, it's faster to remember parts of this table rather than doing the computation. This technique is called memoization.
Pure functional programming languages, as well as languages such as Python and Groovy, have ways to enable memoization on specific function calls, thus providing a high level of control. Unfortunately, C++ doesn't have this facility, so we'll have to write it ourselves.