Given a templated class, how do I define a (further templated) method out of line? The syntax
template<class T> class C {
public:
template<class S> void f();
};
template<class S, class T> void C<T>::f<S>(){}
or any variant I have tried does not do the job:
error: use 'template' keyword to treat 'f' as a dependent template name
template<class S, class T> void C<T>::f<S>(){
^
template
error: nested name specifier 'C<T>::' for declaration does not refer into a class, class template or class template partial specialization
>Solution :
You need to write two template headers:
template<class T>
template<class S>
void C<T>::f(){}