Generic Programming with C++ Template
■ このスレッドは過去ログ倉庫に格納されています
006753
NGNGtemplate<int N, int X>
class Pow
{
public:
static const int reult =
(N%2==1)?X:1)*(Pow<(N>>1)>::result)*(Pow<(N>>1)>::result);
};
template<int X>
class Pow<0, X>
{
public:
static const int result = 1;
};
//...
const int pow5_5 = Pow<5,5>::result;
//...
■ このスレッドは過去ログ倉庫に格納されています