Is it legal in C ++ to create a specification for a base class of a class template B
depending on the private definitions of a class A
that is friendly with the class template B
? Code example:
struct Empty {};
template <typename T>
struct B;
struct A
{
friend struct B<A>;
private:
using Base = Empty;
};
template <typename T>
struct B : T::Base
{
};
int main()
{
B<A> test;
return 0;
}
Link Godbolt: https://godbolt.org/g/HFKaTQ
The code compiles using the Clang trunk (and older versions) and MSVC 19 (VS 2017), but it does not compile with the GCC trunk (and older version):
test.cpp: In instantiation of 'class B<A>':
test.cpp:21:7: required from here
test.cpp:15:8: error: 'using Base = class Empty' is private within this context
struct B : T::Base
^
test.cpp:11:20: note: declared private here
using Base = Empty;
^
Which compiler is wrong?
EDIT: , GCC, B
( ). , . cppreference : " ( ++ 11)"