以下代码在Linux和Aix中编译,但在Sun solaris版本5.12 c ++编译器上编译。有什么建议,如何让它发挥作用?
template <class T>
struct SpecTemp
{
};
template <class T>
struct UnspecTemp
{
typedef T type;
};
struct TestType {};
template <>
struct SpecTemp<TestType>
{
typedef TestType type;
};
template <>
struct UnspecTemp<TestType>
{
};
template <class Hello>
typename SpecTemp<Hello>::type test(Hello help)
{
return help;
}
template <class Hello>
typename UnspecTemp<Hello>::type test(Hello help)
{
return help;
}
template <>
TestType test(TestType)
{
return TestType();
}
int main()
{
TestType a = {};
test(a);
}
这是solaris编译器中的错误。错误如下:
"main.cpp", line 32: Error: type is not a member of UnspecTemp<TestType>.
任何帮助表示赞赏