P
Patrick Kutch
Please take a look at the following code snippit:
-------------------------------------------------------
template<class TraitClass=int>
class TestClass
{
public:
void CallFunc()
{
SpecializedFunct_<TraitClass>();
}
private:
template<class TraitClass >
void SpecializedFunct_(void)
{
// called for non-specialized
}
template<>
void SpecializedFunct_<int>(void)
{
// specialized for TraitClass=int
}
template<>
void SpecializedFunct_<char>(void)
{
// specialized for TraitClass=char
}
};
-------------------------------------------------------
It works GREAT with Visual Studio .NET 2003. Complains to high-heaven with
the gcc 3.2.2 compiler that came with Red Hat Linux 9.0.
I have done some digging and found a few blurbs in my google-mining that
says something to the effect that specialization of member functions for a
non-specialized class is not supported.
So I have 2 questions:
1. Has the standard changed and MS is on the ball, or is it a MS compiler
extension that allows this to work?
2. Would greatly appreciate suggestions on how to get around this issue, I
really really would like to have specialized member functions.
thanx!
-------------------------------------------------------
template<class TraitClass=int>
class TestClass
{
public:
void CallFunc()
{
SpecializedFunct_<TraitClass>();
}
private:
template<class TraitClass >
void SpecializedFunct_(void)
{
// called for non-specialized
}
template<>
void SpecializedFunct_<int>(void)
{
// specialized for TraitClass=int
}
template<>
void SpecializedFunct_<char>(void)
{
// specialized for TraitClass=char
}
};
-------------------------------------------------------
It works GREAT with Visual Studio .NET 2003. Complains to high-heaven with
the gcc 3.2.2 compiler that came with Red Hat Linux 9.0.
I have done some digging and found a few blurbs in my google-mining that
says something to the effect that specialization of member functions for a
non-specialized class is not supported.
So I have 2 questions:
1. Has the standard changed and MS is on the ball, or is it a MS compiler
extension that allows this to work?
2. Would greatly appreciate suggestions on how to get around this issue, I
really really would like to have specialized member functions.
thanx!