nested template syntax

What is the correct syntax here?

1
2
3
4
5
6
7
8
9
10
template<class T>
struct s {
    template<class U>
    void f();
};

template<class T, class U>
void s<T>::f() {
   //...
}
Why don't you try it?

Anyway, notice that template<class T, class U> applies both templates to the function
I tried this, but this gave me a
8: error: prototype for 'void s<T>::f()' does not match any in class 's<T>'
4: error: candidate is: template<class T> template<class U> void s::f()

That's why I asked.
Anyway, notice that template<class T, class U> applies both templates to the function


I don't understand what you say, you can use both templates in the function, although one of them has a bigger scope.


4: error: candidate is: template<class T> template<class U> void s::f()

This is giving you the answer

With C++ highlighted:
"candidate is template<class T> template<class U> void s::f()"
Well, I never thought this could be valid. Thx Bazzy
Topic archived. No new replies allowed.