title: using mem_fun() for container of smart pointers
body: <p>I have recently taken the decision of changing a vector of pointers into a vector of smart pointers, but although these smart pointers are STL-compatible, I could not convert some algorithms to use them.</p>
  
  <p>Consider a</p>
  
  <pre><code>class Base
  {
       ...
       virtual bool valid();
  };
  </code></pre>
  
  <p>How do you convert </p>
  
  <pre><code>bool is_any_valid( vector&lt; Base* &gt; v )
  {
      return v.end() != 
          find_if( v.begin(), v.end(), mem_fun( &amp;Base::valid ) );
  }
  </code></pre>
  
  <p>into this ?</p>
  
  <pre><code>bool is_any_valid( vector&lt; my_smart_ptr&lt; Base &gt; v )
  {
      // mem_fun() fails, because valid() is not a member of my_smart_ptr&lt; Base &gt; !!! 
      // return v.end() != 
      //    find_if( v.begin(), v.end(), mem_fun( &amp;Base::valid ) );
  }
  </code></pre>
  
  <p>You can assume that my_smart_pointer&lt;> has essentially the same interface as shared_ptr&lt;>,
  but I can't use boost in my project.</p>
  
  <p>Is there a (generic) adapter I could write to allow mem_fun or mem_fun_ref to work?
  I preferably look for an in-line solution, like:</p>
  
  <pre><code> find_if( v.begin(), v.end(), mem_fun( some_adapter( &amp;Base::valid ) ) );
  </code></pre>
  
  <p>because there are many similar occurrences of such lines.</p>