The following code example is taken from the book
 
  C++ Templates - The Complete Guide
 by David Vandevoorde and Nicolai M. Josuttis, Addison-Wesley, 2002
 
  © Copyright David Vandevoorde and Nicolai M. Josuttis 2002
#ifndef ACCUM_HPP
#define ACCUM_HPP
#include "accumtraits4.hpp"
template <typename T,
          typename AT = AccumulationTraits<T> >
class Accum {
  public:
    static typename AT::AccT accum (T const* beg, T const* end) {
        typename AT::AccT total = AT::zero();
        while (beg != end) {
            total += *beg;
            ++beg;
        }
        return total;
    }
};
#endif // ACCUM_HPP