title: Class that contains a set of itself with a custom comparer--circular reference
body: <p>Here's the goal (code simplified, of course):</p>
  
  <pre><code>#include &lt;set&gt;
  
  struct Node
  {
     int Value;
     std::set&lt;Node*, CompareNodes&gt; Children;
  };
  
  struct CompareNodes
  {
     bool operator()(const Node* l, const Node* r)
     {
        return l-&gt;Value &lt; r-&gt;Value;
     }
  };
  </code></pre>
  
  <p>But this doesn't compile; the type <code>CompareNodes</code> is unknown when it's encountered inside of <code>Node</code>. I could reverse the order, but then I have the opposite problem--<code>Node</code> would be unknown when it was encountered inside of <code>CompareNodes</code>. Forward declaration doesn't help in either case because each type uses the other in a way that requires its full definition. An ugly workaround is this:</p>
  
  <pre><code>#include &lt;set&gt;
  
  template&lt;typename T&gt;
  struct CompareNodes
  {
     bool operator()(const T* l, const T* r)
     {
        return l-&gt;Value &lt; r-&gt;Value;
     }
  };
  
  struct Node
  {
     int Value;
     std::set&lt;Node*, CompareNodes&lt;Node&gt;&gt; Children;
  };
  </code></pre>
  
  <p>Is there a better way? Bonus points if the answer will work even when <code>Node</code> is an inner class.</p>