使用引用基类的成员模板的声明.

4 c++ templates

任何人都可以解释这个

 "A using-declaration in a derived class cannot refer to a specialization 
 of a template conversion function in a base class."
Run Code Online (Sandbox Code Playgroud)

它来自ISO C++标准.14.5.2,第7点

Joh*_*itb 5

这意味着这是不正确的:

struct A { template<typename T> operator T(); };
struct B : A { using A::operator int; }; // ill-formed: refers to specialization
Run Code Online (Sandbox Code Playgroud)

同样适用于其他功能模板专业化(不仅仅是转换功能)

struct A { template<typename T> void f(); };
struct B : A { using A::f<int>; }; // ill-formed: refers to specialization
Run Code Online (Sandbox Code Playgroud)

  • 我已经向clang开发者发送了一个PR:http://llvm.org/bugs/show_bug.cgi?id = 7922 (2认同)
  • @chubsdad我认为最好的方法是在comp.std.c ++中提问 (2认同)