Hello!
I'm trying to specialize a member function template of a class template,
like this:-
template<typena me Tclass thingy {
public:
template<typena me UT f (const U &) const;
};
// The general case:-
template<typena me Ttemplate<typen ame UT thingy<T>::f
(const U &x) const {
return T(x);
}
// The special case:-
template<typena me Ttemplate<T thingy<T>::f<T>
(const T &x) const {
return x;
}
But it's not working :-( I've tried a few variations (such as throwing
in a 'template' to disambiguate), but my compilers (G++ 4.1.2 and G++
3.3.6) just don't seem to like it. With the above C++, I'm getting the
following out of G++ 4.1.2:-
templates.cpp:1 3: error: invalid explicit specialization before ‘>’ token
templates.cpp:1 3: error: enclosing class templates are not explicitly
specialized
templates.cpp:1 4: error: template-id ‘f<T>’ for ‘T thingy<T>::f(co nst
T&) const’ does not match any template declaration
templates.cpp:1 4: error: invalid function declaration
:-(
What am I doing wrong?
Simon
--
What happens if I mention Leader Kibo in my .signature?