Books

Template Comparison

C++ pioneered templates and template metaprogramming, and continues
to improve on it with C++0x.
The D programming language is the first to comprehensively reengineer
templates based on the C++ experience.
Since C++0x is not a ratified standard yet, proposed changes to C++
are subject to change.

Template Comparison Table

Feature

D

C++98

C++0x

Argument list delineation

Uses !( ), as in Foo!(int). Can omit parens when the argument is a single lexical token: Foo!int

Uses < > as in Foo<int>

No change

Class Templates

Yes:

class Foo(T)
{
T x;
}

Yes:

template<class T>
class Foo
{
T x;
};

No change

Function Templates

Yes:

T foo(T)(T i)
{
...
}

Yes:

template<class T>
T foo(T i)
{
...
}

No change

Member Templates

Yes

Yes

No change

Constructor Templates

No

Yes

No change

Parameterize any Declaration

Yes, classes, functions, typedefs,
variables, enums, etc. can be parameterized,
such as this variable:

template Foo(T)
{
static T* p;
}

No, only classes and functions

No change

Template Typedefs: Create an alias that binds to some but not all
of the template parameters