如何在模板基类中调用模板成员函数?

在基类中调用非模板化成员函数时,可以将其名称用
using
导入到派生类中,然后使用它。这也适用于基类中的模板成员函数吗? 只是使用
using
它不起作用(使用g ++ - snapshot-20110219 -std = c ++ 0x):
template <typename T>
struct A {
  template <typename T2> void f() {  }
};

template <typename T>
struct B : A<T> {
  using A<T>::f;

  template <typename T2> void g() {
    // g++ throws an error for the following line: expected primary expression before `>`
    f<T2>();
  }
};

int main() {
  B<float> b;
  b.g<int>();
}
我知道明确地为基类添加前缀
    A<T>::template f<T2>();
工作正常,但问题是:是否有可能没有和使用简单的使用声明(就像
f
不是模板功能的情况一样)? 万一这是不可能的,有谁知道为什么?     
已邀请:
这是有效的(双关语):
this->template f<T2>();
那样做
template <typename T>
struct B : A<T> {
  template <typename T2> void f()
  { return A<T>::template f<T2>(); }

  template <typename T2> void g() {
    f<T2>();
  }
};
为什么
using
不适用于模板相关的模板函数非常简单 - 语法不允许在该上下文中使用所需的关键字。     
我相信你应该使用:   
this->A<T>::template f<T2>();
要么:   
this->B::template f<T2>();
    

要回复问题请先登录注册