#include <iostream>using namespace std; class C{public: template<typename T> void f(T t);}; template<typename T>void C::f(T t){ cout << t << endl;} template<typename T>void C::f<T*>(T* pt){ cout << "(pointer specialization) " << *pt << endl;} int main(){ C c; c.f(0); c.f(&c); return 0;}
prog.cpp:18:20: error: function template partial specialization ‘f<T*>’ is not allowed prog.cpp:18:6: error: prototype for ‘void C::f(T*)’ does not match any in class ‘C’ prog.cpp:8:10: error: candidate is: template<class T> void C::f(T)
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!