I am trying to port the following code. I know the standard doesn\'t allow explicit specialization in non-namescape scope and I should use overloading, but I just can\'t fin
Define the specialization outside the class as:
template <>
bool VarData::IsTypeOf < int > (int index) const
{ //^^^^^^^^^ don't forget this!
return false;
}
template <>
bool VarData::IsTypeOf < double > (int index) const
{ //^^^^^^^ don't forget this!
return false;
}
You just have to move your specializations of the member templates outside of the class body.
class VarData
{
public:
template < typename T > bool IsTypeOf (int index) const
{
return IsTypeOf_f<T>::IsTypeOf(this, index);
}
};
template <> bool VarData::IsTypeOf < int > (int index) const
{
return false;
}
template <> bool VarData::IsTypeOf < double > (int index) const
{
return false;
}