Also, calculating things at compile time is just one aspect of template metaprogramming.
For example, consider something like the BOOST_FOREACH macro (thankfully it will be replaced with a built-in construct). There is actually a lot of type-deducing going on underneath to support all the iterable types: C style strings, arrays and classes having a begin() and end() method.
Code:
#include <iostream>
#include <vector>
#include <boost/foreach.hpp>
int main()
{
char* str = "Hello!";
int arr[] = { 1, 2, 3, 4, 5 };
std::vector<int> vec(3, 42);
BOOST_FOREACH( char c, str ) {
std::cout << c << ' '; //H e l l o !
}
std::cout << '\n';
BOOST_FOREACH( int n, arr ) {
std::cout << n << ' '; //1 2 3 4 5
}
std::cout << '\n';
BOOST_FOREACH( int n, vec ) {
std::cout << n << ' '; //42 42 42
}
std::cout << '\n';
/*
doesn't compile:
int* p = arr;
BOOST_FOREACH( int n, p ) {
std::cout << n << ' ';
}
*/
}