c++ template syntax

前端 未结 1 702
独厮守ぢ
独厮守ぢ 2021-01-21 00:50

How do I fix this syntax error?

struct A {
  template < typename T >
  void f () {}
};

template < typename C, typename U >
struct B {
  void g () {
         


        
相关标签:
1条回答
  • 2021-01-21 01:10

    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.

    0 讨论(0)
提交回复
热议问题