What is the legal syntax for defining a nested template?

I have the following nested template

class A { template <typename T> class B { template <typename U> void foo(U arg); }; }; 

I am trying to define a nested template as follows:

 template <typename T, typename U> void A::B<T>::foo(U arg) {...} 

But I get the error declaration is incompatible with function template . What is the legal syntax for this?

+7
source share
1 answer

You need to separate the template ads:

 template <typename T> template <typename U> void A::B<T>::foo(U arg) { โ€ฆ } 
+10
source

All Articles