If I have a class A that is templated on type T, and that class has a method Foo that is templated on type U
template <class T>
class A
{
public:
template <class U>
void Foo();
};
To define that function outside the class I need two template statements like so
template <class T>
template <class U>
void A<T>::Foo() {} // this compiles
The following does not compile
template <class T, class U>
void A<T>::Foo() {} // this does not compile
with the error
prog.cpp:10:6: error: no declaration matches ‘void A<T>::Foo()’
void A<T>::Foo() {}
^~~~
prog.cpp:6:7: note: candidate is: ‘template<class T> template<class U> void A<T>::Foo()’
void Foo();
^~~
prog.cpp:2:7: note: ‘class A<T>’ defined here
class A
^
Is there a more terse/compact way to define both template types in a single statement like above?