//
// powtemplate.cc for PowTemplate in /
//
// Made by Averous Julien-Pierre
// Login   <j.averous@sourcemac.com>
//
// Started on  Wed May 16 18:29:12 2007 Averous Julien-Pierre
// Last update Wed May 16 18:33:44 2007 Averous Julien-Pierre
//

#include <iostream>

/*
** Here the general definition of our "pow" structure.
** We did the recursion with this.
*/
template <unsigned int x, unsigned int n>
struct pow
{
  static const int value = x * pow<x, n - 1>::value;
};


/*
** Here the end case with n = 0
*/
template <unsigned int x>
struct pow <x, 0>
{
  static const int value = 1;
};

/*
** Just ask to generate the full code of the recursive template
** with the access to the "value" field of the templated pow structure
*/
int main ()
{
  int v = pow <12, 4>::value;

  std::cout << "12 ^ 4 = " << v << std::endl;

  return 0;
}
