[英]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>();
但是,当U
是A
,这仍然无效,因为f
不是A
的static
成员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.