Skip to content

Instantly share code, notes, and snippets.

@aont
Created August 25, 2011 03:42
Show Gist options
  • Select an option

  • Save aont/1169930 to your computer and use it in GitHub Desktop.

Select an option

Save aont/1169930 to your computer and use it in GitHub Desktop.
double value template
#include <iostream>
using std::size_t;
template<typename _base, size_t _index>
class pow_i
{
public:
const static double value = pow_i<_base, _index-1 >::value * _base::value;
};
template<typename _base>
class pow_i<_base, 0>
{
public:
const static double value = 1;
};
class ten
{
public:
const static double value = 10;
};
int main()
{
std::cout << pow_i<ten, 5>::value << std::endl;
return 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment