namespace detail
{
template<class T, int N>
struct helper
{
static constexpr T pow(const T x){
return helper<T, N-1>::pow(x) * x;
}
};
template<class T>
struct helper<T, 1>
{
static constexpr T pow(const T x){
return x;
}
};
template<class T>
struct helper<T, 0>
{
static constexpr T pow(const T x){
return 1;
}
};
}
template<int N, class T>
T constexpr pow(T const x)
{
return detail::helper<T, N>::pow(x);
}
#include <iostream>
int main()
{
std::cout << pow<5>(4);
}
ICAgIG5hbWVzcGFjZSBkZXRhaWwKICAgIHsKICAgICAgICB0ZW1wbGF0ZTxjbGFzcyBULCBpbnQgTj4KICAgICAgICBzdHJ1Y3QgaGVscGVyCiAgICAgICAgewogICAgICAgICAgICBzdGF0aWMgY29uc3RleHByIFQgcG93KGNvbnN0IFQgeCl7CiAgICAgICAgICAgICAgICByZXR1cm4gaGVscGVyPFQsIE4tMT46OnBvdyh4KSAqIHg7CiAgICAgICAgICAgIH0KICAgICAgICB9OwoKICAgICAgICB0ZW1wbGF0ZTxjbGFzcyBUPgogICAgICAgIHN0cnVjdCBoZWxwZXI8VCwgMT4KICAgICAgICB7CiAgICAgICAgICAgIHN0YXRpYyBjb25zdGV4cHIgVCBwb3coY29uc3QgVCB4KXsKICAgICAgICAgICAgICAgIHJldHVybiB4OwogICAgICAgICAgICB9CiAgICAgICAgfTsKCiAgICAgICAgdGVtcGxhdGU8Y2xhc3MgVD4KICAgICAgICBzdHJ1Y3QgaGVscGVyPFQsIDA+CiAgICAgICAgewogICAgICAgICAgICBzdGF0aWMgY29uc3RleHByIFQgcG93KGNvbnN0IFQgeCl7CiAgICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICAgfQogICAgICAgIH07CiAgICB9CgogICAgdGVtcGxhdGU8aW50IE4sIGNsYXNzIFQ+CiAgICBUIGNvbnN0ZXhwciBwb3coVCBjb25zdCB4KQogICAgewogICAgICAgIHJldHVybiBkZXRhaWw6OmhlbHBlcjxULCBOPjo6cG93KHgpOwogICAgfQoKICAgICNpbmNsdWRlIDxpb3N0cmVhbT4KCiAgICBpbnQgbWFpbigpCiAgICB7CiAgICAgICAgc3RkOjpjb3V0IDw8IHBvdzw1Pig0KTsKICAgIH0K