[quote name='Cornstalks' timestamp='1357885855' post='5020199']
Anyone else have any cool template metaprogramming demos?
[/quote]
Template metaprogramming is cool when it works...
... The problem is when it doesn't compile out.
... Or when someone has to maintain it.
... Or when the code must be supported on multiple compilers.
If the compiler isn't able to discover and take the optimization it will just embed the function calls. These are often deeply-recursive. They also often use algorithms that perform poorly relative to other implementations.
They're great if you're computing a Fibonacci or logarithm of a known constant at compile time. But seriously, how often is that? Even if I did need a logarithm, I'd need to compute it on variables rather than constants.
In code reviews, I am one of many people who routinely reject TMP solutions. Yes they are cool when they work, but they are far too fragile for general case development.