How to fix 'incomplete type' error in a circular dependency?

2 days ago 7
ARTICLE AD BOX

A simplified code of what I have:

template <typename X> struct M { struct V : public X {}; // error: invalid use of incomplete type ‘struct T::U’ struct I { V* p; }; // For simplicity assume that V is somehow used V v; }; struct T { struct U { typename M<U>::I i; }; M<U> m; };

So, T::U needs information about M::I, which uses information about M::V, which is constructed from T::U. Is there a way to solve this cycle?

Read Entire Article