Consider this snippet:
struct S {
template <typename T>
void insert(const T& x);
};
template <>
void S::insert<char*>(const char*& x) {}
int main() {
S s;
s.insert("");
return 0;
}
gcc fails to compile it with the following error message:
error: template-id 'insert<char*>' for 'void S::insert(const char*&)' does not match any template declaration
What's the reason for this error, and is there a way to write the specialization such that it will work?
I'm not looking for an alternative solution, I'm simply trying to understand the logic behind the error.