#include <iostream>
template<bool cond, typename If, typename Then>
struct IF {
typedef If type;
};
template<typename If, typename Then>
struct IF<false, If, Then> {
typedef Then type;
};
template<template<typename> class cond, typename statement>
struct WHILE {
struct STOP {
typedef statement type;
};
typedef typename
IF<cond<statement>::value,
WHILE<cond, typename statement::next>,
STOP
>::type::type type;
};
template<int n, int e>
struct sum_pow {
template<int x>
struct pow {
template<int p, int q>
struct pow_q {
static constexpr int value = p * pow_q<p,q-1>::value;
};
template<int p>
struct pow_q<p, 0> {
static constexpr int value = 1;
};
static constexpr int value = pow_q<x,e>::value;
};
template<typename statement>
struct cond {
static constexpr bool value = statement::iter <= n;
typedef statement type;
};
template<int i, int sum>
struct statement {
typedef statement<i+1, sum+pow<i>::value> next;
static constexpr int iter = i;
static constexpr int value = sum;
};
static constexpr int value = WHILE<cond, statement<1,0>>::type::value;
};
int main(void) {
std::cout << sum_pow<10,2>::value << std::endl;
return 0;
}