Template metaprogram sample
template<int N> struct Factorial
{
enum
{
value = N * Factorial<N-1></n-1>::value
};
};
templatestruct Factorial<1>
{
enum { value = 1 };
};
int i = Factorial<10>::value;
This simple template can be used to calculate factorial during compilation.
Template metaprograms - by Todd Velthuizen
Spirit parser - advanced metaprogramming
Boost - portable C++ libraries
Adobe - Simulated partial Specialization for C++ for Microsoft C++ users, I hope that the new compiler will soon support PTS.