Darren New <dne### [at] sanrrcom> wrote:
> http://www.rubinsteyn.com/template_insanity.html
Template metaprogramming is really mean to compilers. This is because
template metaprogramming is in practice functional programming where loops
are made exclusively by recursion. Recursions need stacks or other forms
of keeping track of where we are, and thus the memory usage is proportional
to the number of recursions. (In many functional languages tail recursion
can be optimized internally into a non-recursive loop, but you can guess
if C++ compilers support the notion of "tail recursion" with templates...)
In template metaprogramming a recursive loop means in practice that the
name of the templated type is very long (each "loop" makes the name longer).
Most compilers have a fixed amount of memory allocated for demangling
template types. Thus they support only a very small amount of recursions.
In some compilers you can increase this limit with a command-line parameter
(eg. gcc supports this), but it's still fixed.
--
- Warp
Post a reply to this message
|