[英]g++: error: there are no arguments to 'pow' that depend on a template parameter, so a declaration of 'pow' must be available [-fpermissive]
This code compiled properly on Visual Studio 2010 on Windows, but I'm getting this error on Linux, g++. 这段代码可以在Windows的Visual Studio 2010上正确编译,但是在Linux,g ++上却出现此错误。 Could anyone please explain how to fix this?
有人可以解释如何解决此问题吗?
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];
}
}
Error message: 错误信息:
error: there are no arguments to 'pow' that depend on a template parameter, so a declaration of 'pow' must be available [-fpermissive] 错误:“ pow”没有依赖模板参数的参数,因此“ pow”的声明必须可用[-fpermissive]
Thank you. 谢谢。
您需要#include <cmath>
并在数学库中使用-lm
链接(在某些系统上)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.