有人可以帮我把以下代码移植到GCC?我发现了很多或本网站相关的问题,但我似乎只是没有我的情况下,申请建议的解决办法...非命名空间范围错误显式专精...迫切需要帮助
typedef float MyData __attribute__ ((__vector_size__ (16)));
template <typename T> class Data_T
{
public:
template < typename U > static bool IsEqual (const T & a, const T & b)
{
return a == b;
}
//Fixed: template <> static bool IsEqual <MyData> (const MyData & a, const MyData & b)
static bool IsEqual (const MyData & a, const MyData & b)
{
return true;
}
void TriggerProblem(const T & val)
{
if (!IsEqual(1.0f, val)) // Error: no matching function for call to 'Data_T<float>::IsEqual(float, const float&)'
{
}
}
};
代码触发问题:
Data_T<MyData> inst;
inst.TriggerProblem(1.0f);
我得到一个错误错误:在非名称空间范围'类Data_T'中显式专门化,这是由专业化函数IsEqual()引起的,但现在遇到另一种类型的错误(没有用于调用'Data_T :: IsEqual(float,const float &)'),这似乎是由我无法删除的__vector_size__属性造成的。请帮助...
C99与它有什么关系,这是C++代码? – jonsca 2011-04-19 10:04:37
对不起,我的意思是ISO/IEC 14882:2003标准 – Ryan 2011-04-19 10:19:48