Listing 3

// Loop<> implementation

// primary template
template < int start, int end >
struct Loop
{
    template <typename T >
    static void eval( T& expr)     {
        expr(start) ;                    // do work
        Loop<start+1,end>::eval(expr) ;   // increment argument and 				         // recurse
    }
};
// specialization
template <int end >
struct Loop <end, end>
{
    template <typename T>
    static void eval( T& expr)    {
        expr(end);
    }
};