Comparison chart of D and C++ templates

Don Clugston dac at nospam.com.au
Fri Jan 19 10:11:55 PST 2007


Lutger wrote:
> Walter Bright wrote:
>> http://www.digitalmars.com/d/template-comparison.html
>>
>> Comments?
> 
> Informative chart, links to spec and other articles about templates 
> might be useful.
> 
> Not sure if these belong to the chart, but I find the following features 
>   quite valuable with or in conjunction with templates:
> 
> - Static assert, a no-brainer.
> - Compile time messages, with static assert for example. I guess this by 
> virtue of the .mangleof property with compile time string parsing? (I'm 
> thinking of Don Clugston's meta.nameof library). Anyway the ability to 
> easily give meaningful and readable error messages without resorting to 
> compiler output parsing like STLlift can be a big time-saver.
> - 'is' expressions

All of these together give a large part of the functionality of C++0x 
concepts.

void remove_if(T)(T start, T end) {
static assert(isForwardIterator!(T), prettytypeof!(T) ~ " is not a 
forward iterator");
...
}

> - templated mixins



More information about the Digitalmars-d-announce mailing list