vitaut
vitaut

Reputation: 55615

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

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

Answers (1)

T.C.
T.C.

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

Related Questions