求助,模板元,非类型模板参数编译错误
一段用来静态计算乘方的模板元代码。
用double作为第一类型参数的时候无法通过编译。
那位大神解释一下。。
template<class T,T _Numer,unsigned int powst>
class static_power
{
public:
static T const value = static_power<T,_Numer,powst-1>::value*_Numer;
};
template<class T,T _Numer>
class static_power<T,_Numer,0>
{
public:
static T const value =T(1);
};
int main()
{
std::cout<<static_power<double,2.0,31>::value<<endl;
return 0;
}