If I setup the following template method of a template class foo:func
template<typename T>
class foo{
public:
template<typename U> static void func(){}
};
int main(){
foo<int>::func<long>();
}
everything works fine. When I try to call foo::func
from a template class
template<typename T>
class foo{
public:
template<typename U>
static void func(){}
};
template<typename T,typename U>
class bar{
public:
bar(){
foo<T>::func<U>();
}
};
int main(){
bar<int,long> b;
foo<int>::func<long>();
}
I get the following compile error:
main.cpp: In constructor ‘bar<T, U>::bar()’:
main.cpp:13:19: error: expected primary-expression before ‘>’ token
foo<T>::func<U>();
^
main.cpp:13:21: error: expected primary-expression before ‘)’ token
foo<T>::func<U>();
^
How can I call foo::func
from the template class bar
?