Hi,
I have a problem with a template function inside a class (no template).
The template parameter of the class is a policy class.
But the explicit specialization of the template function does not work.
Visual C++ 7.1 compiler said that the function cannot be explicitly
specialized.
But the same code compiles with the Comeau online compiler
successfully.
Here's a simplyfied version of the code (with same effect Comeau -> ok,
VC++ 7.1 -> error):
class Policy1
{
public:
typedef int type;
};
class Policy2
{
public:
typedef long type;
};
class ClassX
{
public:
template<typename PolicyT>
bool func(typename PolicyT::type arg);
};
template<>
bool ClassX::func<Policy1>(Policy1::type arg)
{
/* do something */
return true;
}
template<>
bool ClassX::func<Policy2>(Policy2::type arg)
{
/* do something */
return true;
}
int main()
{
ClassX x;
x.func<Policy1>(12);
}
Can anyone tell me, why this does not work (with VC++7.1)?
Thx in advance,
Georg