title: std::shared_ptr with std containers
body: <p>I have a container of <code>shared_ptr</code>s and I hand these objects off to a windows API and I get a callback later with the raw ptr. I want to locate the right <code>shared_ptr</code> after the fact. Can this be done with shared_ptr cleanly? (without using <code>shared_from_this()</code>).</p>
  
  <p>very basic example:</p>
  
  <pre><code>class CFoo
  {
  };
  typedef std::shared_ptr&lt;CFoo&gt; CFooPtr;
  typedef std::set&lt;CFooPtr&gt; CFooSet;
  
  extern CFooSet m_gSet;
  void SomeWindowsCallBack(CFoo* pRawPtr)
  {
    m_gSet.erase(pRawPtr);
  }
  </code></pre>
  
  <p>I know that this can be done with <code>intrusive_ptr</code> very easily but I am curious if there is a way with <code>shared_ptr</code>. Aka I am looking for the container to accept the RawPtr and the shared_ptr for locating the <code>shared_ptr</code> item. The issue is that I can't implicitly cast the <code>CFoo*</code> into the shared_ptr (for reasons I do understand). </p>
  
  <p>I was thinking I could do</p>
  
  <p><code>m_gSet.erase(shared_ptr&lt;CFoo&gt;(pRawPtr, _do_not_delete_deleter))</code></p>
  
  <p>but I have not tried that yet and it seems dangerous/ugly. Is there another way or am I basically looking for <code>intrusive_ptr</code>? Thanks</p>