POV-Ray : Newsgroups : povray.off-topic : Mildly interesting article : Re: Mildly interesting article Server Time
11 Oct 2024 07:12:58 EDT (-0400)
  Re: Mildly interesting article  
From: Warp
Date: 11 Nov 2007 18:47:13
Message: <47379480@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.