compiled the following code
Code:
class t {
public:
template <typename T>
void tt(T i) { }
template <>
void tt(int i) { }
};
int main()
{
}
and I got the following error message
5 invalid explicit specialization before '>' token
5 explicit specialization in non-namespace scope `class t'
6 invalid member function declaration
but if I moved function tt out of the class t, say,
Code:
template <typename T>
void tt(T i) { }
template <>
void tt(int i) { }
int main()
{
}
then it compiled well.
I wonder if C++ dosen't support such kind of specialization inside a class? Why? For any good reason?
Anyway, I do need to declare a template function, and a special version of this function, inside a normal class. How? The only alternative is to make it an overloaded function? say,
Code:
class t {
public:
template <typename T>
void tt(T i) { }
void tt(int i) { }
};
int main()
{
}
then it compiled well