On the richness of C++

Walter Bright newshound1 at digitalmars.com
Tue Apr 15 11:29:22 PDT 2008


Edward Diener wrote:
> Thanks for the examples above. I do realize that D has some built-in 
> features which enable template manipulation which Boost MPL has to 
> emulate through some very clever C++ template metaprogramming. In 
> particular, as you have shown above, D has the tuple concept, the static 
> if...else, and also something I like quite a bit, which is that there is 
> no necessity for a base template upon which specializations are built 
> but that each template can be defined with its own specializations. That 
> last feature makes D templates really much easier to write.

One aspect of C++ templates is rendered completely irrelevant in D is 
D's ability to do compile time function execution. Any C++ 
metaprogramming that computes a value can be replaced in D with an 
ordinary function, that is then executed at compile time.

Other things that help are D's ability to pass strings as template 
arguments, and parse those strings at compile time, and D's ability to 
access local variables (not just globals) from template expansions.



More information about the Digitalmars-d mailing list