title: C++ STL set: Compare object with extrinsic state
body: <p>This definitions are inside of <code>OuterClass</code>:</p>
  
  <pre><code>struct Compare
  {
      bool operator ()(const T&amp;, const T&amp;);
  };
  typedef set&lt;T, Compare&gt; MySet;
  </code></pre>
  
  <p>My problem is that the compare function <code>operator ()</code> depends on the state of <code>OuterClass</code>. (<code>MySet</code> instances are used during an algorithm for an optimization and they have to sort differently at different stages.)</p>
  
  <p>Is there any way/workaround to access nonstatic members of <code>OuterClass</code> from within the compare function <code>operator ()</code>?</p>