繁体   English   中英

c ++模板语法

[英]c++ template syntax

如何修复此语法错误?

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 ();
}

U是依赖类型,因此您需要指定f是模板成员:

U::template f<C>();

但是,当UA ,这仍然无效,因为f不是Astatic成员。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM