![](/img/trans.png)
[英]Why is this class's own protected member inaccessible from a template method?
[英]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.