Let's turn the problem inside-out with a sprinkle of user-defined types to break the declarations' recursion :
struct Node {
int _value;
std::list<Node>::const_iterator _next;
};
If you want to use a typedef, well you can :
struct Node;
typedef std::list<Node> NodeList;
struct Node {
int _value;
NodeList::const_iterator _next;
};
Edit: As T.C. reminded me, instantiating standard containers with incomplete types may be Undefined Behaviour (some standard library implementations do guarantee it's not). So, let's postpone all of it to a later point.
Edit: Well that doesn't help either. So, verify that your std::list
implementation supports incomplete types (or trust it to do so, it often works to be honest), or use Boost::containers.
template <class = void>
struct Node_ {
int _value;
typename std::list<Node_>::const_iterator _next;
};
typedef Node_<> Node;