[ACCEPTED]-GCC error: explicit specialization in non-namespace scope-gcc
Accepted answer
You just have to move your specializations 2 of the member templates outside of the class 1 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;
}
Define the specialization outside the class 1 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;
}
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.