C ++ - circular dependency (using the internal type of the subclass in the template base class)

I ran into a circular dependency problem in a template class. There is an example code:

template <typename T> struct A { typedef typename T::CD; //typename T::C c; }; struct B : public A<B> { struct C {}; }; 

When I try to create an instance of B, I get a compiler error: "C" is not a member of "B" (MSVC) or "Invalid use of an incomplete type" struct B "(GCC).
What is the best way to modify a pattern to make it work?

+7
source share
1 answer
 struct B_base { struct C {}; }; strucr B : A<B_base>, B_base { }; 
+6
source