繁体   English   中英

为什么私有基类的成员模板引入了使用声明不可访问?

[英]Why is a member template from private base class introduced with a using declaration inaccessible?

考虑以下(人为)示例:

class A {
 public:
  template <typename T>
  class C {};
};

class B : private A {
 public:
  using A::C;
};

int main() {
  B::C<int> c;
}

它与GCC和Clang成功编译,但Visual C ++ 2010出现以下错误:

test.cpp(13):错误C2247:'A :: C'无法访问,因为'B'使用'private'继承'A'

这是Visual C ++中的错误还是这段代码确实无效?

如果C不是模板,则代码将编译在所有编译器上。

[namespace.udecl] / P18:

using-declaration创建的别名具有成员声明的通常可访问

这里不多说。 名称B::C可公开访问,代码格式正确。 只是另一个MSVC错误。

暂无
暂无

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

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