C ++ Template Syntax

How to fix this syntax error?

struct A { template < typename T > void f () {} }; template < typename C, typename U > struct B { void g () { U::f < C > (); // expected primary-expression before ยป>ยซ token } }; int main () { B<int,A> b; bg (); } 
+3
c ++ templates
01 Sep '10 at 20:03
source share
1 answer

U is a dependent type, so you need to indicate that f is a member of the template:

 U::template f<C>(); 

This is still not valid if U is A , although f not a static member of A

+9
Sep 01 '10 at 20:05
source share



All Articles