template<int level> struct tower { template<class T, class U> constexpr static auto op(T t, U u) { T ret{1}; for (U i = 0; i < u; i++) ret = tower<level - 1>::op(t, ret); return ret; } }; template<> // pow(t, u); struct tower<1> { template<class T, class U> constexpr static auto op(T t, U u) { T ret{1}; for (U i = 0; i < u; i++) ret *= t; return ret; } };
int main() { std::cout << tower<2>::op(uint64_t(3), 3) << std::endl; }