compiled the following code
and I got the following error messageCode:class t { public: template <typename T> void tt(T i) { } template <> void tt(int i) { } }; int main() { }
but if I moved function tt out of the class t, say,5 invalid explicit specialization before '>' token
5 explicit specialization in non-namespace scope `class t'
6 invalid member function declaration
then it compiled well.Code:template <typename T> void tt(T i) { } template <> void tt(int i) { } int main() { }
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,
then it compiled wellCode:class t { public: template <typename T> void tt(T i) { } void tt(int i) { } }; int main() { }



LinkBack URL
About LinkBacks



