I'm getting a truly bizarre error message from gcc 4.6 about a template member function. Here is a minimal example:
template<typename T>
class Pimpl
{
public:
Pimpl(const Pimpl&) {}
private:
T* clone_(const T*);
};
template<typename T>
template<typename P>
T*
Pimpl<T>::clone_(const T*)
{
return new P(static_cast<const P&>(*p));
}
Here is the error:
$ c++ -c y.cpp
y.cpp:14:1: error: prototype for ‘T* Pimpl<T>::clone_(const T*)’ does not match any in class ‘Pimpl<T>’
y.cpp:8:8: error: candidate is: T* Pimpl<T>::clone_(const T*)
Note that the non-matching prototype is exactly the same as the candidate one.
What gives?