On the richness of C++

Walter Bright newshound1 at digitalmars.com
Tue Apr 15 11:21:20 PDT 2008


Edward Diener wrote:
> The question is: has anyone tackled in D some of the template 
> metaprogramming tasks which various Boost programmers have accomplished 
> with C++ ?

Yes. See std.algorithms, for one. It is written by Andrei Alexandrescu, 
the guy who revolutionized template programming in C++ with his book 
"Modern C++ Design."

> I am trying to get a feel for how different, or how much easier ( or 
> perhaps harder ) it would be to do Boost things like Spirit ( 
> lex/yacc-like DSEL ),

I wrote a toy Spirit clone a while back, just as a proof of concept. It 
is very doable.

> function ( universal callable ), bind and/or 
> lambda ( function object creation ),

I believe that closures and delegates make those irrelevant.

> shared_ptr ( sharable smart 
> pointer, obviously for RAII in D because of GC ),

Coming with RAII for structs.

> signals ( generalized 
> multicast events ), multi_index ( multiple index containers ),

I'm not sure what those require of templates.

> regex and/or xpressive ( regular expressions ),

Don Clugston showed how you can to regex in D.

> tokenizer ( generalized 
> tokening of strings ), date_time ( date/time and time intervals ) and 
> many others ( the above are just my favorites but I have hardly 
> explored/used all of them ) which C++ programmers find very useful. All 
> of these libraries depend on template metaprogramming in C++. Can their 
> equivalents just as easily be implemented and have any of them been done 
> already ?

Since I've implemented both C++ and D templates, I know what 
capabilities they have. D's exceeds C++'s.

> I have not looked at the D libraries, phobos and tango I believe they 
> are called, so maybe I am way off base comparing the Boost libraries to 
> what may already be in D. But I am trying to get an idea if D is capable 
> of doing these Boost things just as easily or easier.

For one example, I reduced a whole chapter of Andrei's "Modern C++ 
Design" to one page of D, see std.typetuple.



More information about the Digitalmars-d mailing list