Reputation: 55615
Consider the following (artificial) example:
class A {
public:
template <typename T>
class C {};
};
class B : private A {
public:
using A::C;
};
int main() {
B::C<int> c;
}
It compiles successfully with both GCC and Clang, but Visual C++ 2010 gives the following error:
test.cpp(13): error C2247: 'A::C' not accessible because 'B' uses 'private' to inherit from 'A'
Is this a bug in Visual C++ or this code is indeed invalid?
If C
is not a template, the code compiles on all compilers.
Upvotes: 4
Views: 130
Reputation: 137425
[namespace.udecl]/p18:
The alias created by the using-declaration has the usual accessibility for a member-declaration.
Not much to say here. The name B::C
is publicly accessible, and the code is well-formed. Just another MSVC bug.
Upvotes: 5