tags:

views:

67

answers:

1

How do I 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;
  b.g ();
}
+6  A: 

U is a dependent type so you need to specify that f is a template member:

U::template f<C>();

This is still invalid when U is A, though, as f is not a static member of A.

Charles Bailey
Thank you. I didn't know that syntax.
Thomas