- C ++ template. Metaprogramming a form of functional programming?
Oops! The extension of the template has no side effects, so it is purely functional.
If so, do some traps like stackoverflow for irregular recursion relevant for metaprogramming C ++ templates?
That's right. Factorial is not a good demonstration of this, as the result will overflow long before your stack, but long recursions can lead to a compiler error. Interestingly, however, compilers tend to implement templates in such a way that you get automatic memoization. For example, a naively written Fibonacci series implementation will seek to compile in O (n) time, rather than O (2 ^ n).
Sneftel
source share