The*_*ist 4 c++ templates casting g++ type-conversion
此代码在 Windows 上的 Visual Studio 2010 上正确编译,但我在 Linux、g++ 上收到此错误。谁能解释一下如何解决这个问题吗?
int bits;
T scale;
std::vector<U> TwoPowers;
U cropper;
template <typename T, typename U>
ConvertToBits<T,U>::ConvertToBits(int bits, T scale)
{
this->bits = bits;
this->scale = scale;
for(long i = 0; i < 64; i++)
{
TwoPowers.push_back(static_cast<U>(pow(2.,i))); //error appears here
}
cropper = 0;
for(int i = 0; i < bits; i++)
{
cropper += TwoPowers[i];
}
}
Run Code Online (Sandbox Code Playgroud)
错误信息:
错误:“pow”没有依赖于模板参数的参数,因此“pow”声明必须可用 [-fpermissive]
谢谢。