title: inherit from inner class and pass it in on outer template simultaneously?
body: <p>I'm trying to create a tree structure where the user can make their own tree node inheritor, but the node encapsulates some code for managing its position in the tree and exposing children to inheritors. I have code similar to this:</p>
  
  <pre><code>template &lt;typename TData&gt;
  class TreeBase {
  protected:
      struct TreeNode { // should be fully encapsulated
          TData data;
          ...
      };
  public: ...
  };
  
  template &lt;typename TNode&gt;
  struct Tree: public TreeBase&lt;TNode&gt; {
      class Node {
          typename TreeBase&lt;TNode&gt;::TreeNode _tn; // keep encapsulated
      public: ...
      };
      ...
      static_assert(std::is_base_of&lt;Node, TNode&gt;::value, "TNode must be a descendant of NodeTrie::Node");
  };
  </code></pre>
  
  <p>And though the class definitions compile, I can't figure out how to use them. I can't make an inheritor of Node without putting that inside an inheritor of Tree, and I can't make an inheritor of Tree without passing in my node type. It's a chicken &amp; egg problem. Any suggestions?</p>