template<typename T>
class CConstraint
{
public:
CConstraint()
{
}
virtual ~CConstraint()
{
}
template <typename TL>
void Verify(int position, int constraints[])
{
}
template <>
void Verify<int>(int, int[])
{
}
};
Compiling this under g++ gives the following error:
Explicit specialization in non-namespace scope ‘class CConstraint’
In VC, it compiles fine. Can anyone please let me know the workaround?
VC++ is non-compliant in this case – explicit specializations have to be at namespace scope. C++03, §14.7.3/2:
Additionally you have the problem that you can’t specialize member functions without explicitly specializing the containing class due to C++03, §14.7.3/3, so one solution would be to let
Verify()forward to a, possibly specialized, free function: