Using a protected inner class as a base class of other class

59 Views Asked by At

In the section "11.9 Member access control" of the C++20 Standard there is provided an example (p.#7, example #2) of using a protected inner class of a class as a base class for a derived class and the corresponding text relative to such a declaration.

Here is a simplified by me version of the example

class A {
//...
protected:
    struct B { };
};

struct D: A::B, A { };

And there is written

Similarly, the use of A::B as a base-specifier is well-formed because D is derived from A, so checking of base-specifiers must be deferred until the entire base-specifier-list has been seen.

Now from the provided quote it is unclear whether this declaration of the structure D should be compiled

struct D: A::B, A { };

or the compiler will issue an error that the base class A::B is inaccessible. For example the compiler x86-64 clang (trunk) reports an error.

0

There are 0 best solutions below