由于某些原因,我似乎无法在 GCC 中调用全局模板函数 ...
“ globals.h ”中定义的全局函数:
template <typename T1, typename T2> inline T1 Min (const T1 & v1, const T2 & v2)
{
return v1 < v2 ? v1 : v2;
}
从“ test.h ”中定义的类调用函数:
#include "globals.h"
class Test
{
public:
Test()
{
int a = 2;
int b = 3;
int c = Min(a, b); //error: 'Min' was not declared in this scope
int d = ::Min(a, b); //error: '::Min' has not been declared
int e = Min<const int, const int>(a, b); //error: expected primary-expression before 'const'
int f = this->Min(a, b); //error: 'class Test' has no member named 'Min'
}
};
我该怎么办?