The template mechanism in C++ only accidentally became useful for template metaprogramming. On the other hand, D\'s was designed specifically to facilitate this. And apparently
I believe nothing is better qualified to show the incredible power (TM) of the D template system than this renderer I found years ago:
Yes! This is actually what is generated by the compiler ... it is the "program", and quite a colourful one, indeed.
The source seems to be back online.
Well in D you can easily impose static constraints on template parameters and write code depending on the actual template argument with static if.
It's possible to simulate that for simple cases with C++ by using template specialization and other tricks (see boost) but it's a PITA and very limited cause the compiler doesn't expose many details about types.
One thing C++ really just can't do is sophisticated compile time code generation.
Just to counter the D ray tracing post, here is a C++ compile time ray tracer (metatrace):
(by the way, it uses mostly C++2003 metaprogramming; it would be more readable with the new constexpr
s)
There are quiet a few things you can do in template metaprogramming in D that you cannot do in C++. The most important thing is that you can do template metaprogramming WITHOUT SO MUCH OF A PAIN!