title: Delete raw pointer argument to boost::bind
body: <p>Lets say I have heap allocated <code>A*</code>, which I want to pass as argument to <code>boost::bind</code>.
  <code>boost::bind</code> is saved for later processing in some STL like container of <code>boost::functions</code>'s.</p>
  
  <p>I want to ensure <code>A*</code> will be destroyed at destruction of the STL container.</p>
  
  <p>To demostrate:</p>
  
  <pre><code>A* pA = new A();
  
  // some time later
  container.push_back(boost::bind(&amp;SomeClass::HandleA, this, pA);
  
  // some time later
  container is destroyed =&gt; pA is destroyed too
  </code></pre>
  
  <p>How can it be done?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Maybe what I want is not that realistic. </p>
  
  <p>I have raw pointer and function which receives the raw pointer. The call is delayed by means of <strong>boost::bind</strong>. At this point I want automatic memory management in case boost::bind want executed. I'm lazy, so I want to use "ready" smart-pointer solution.</p>
  
  <p><strong>std::auto_ptr</strong> looks like a good candidate, however ...</p>
  
  <pre><code>auto_ptr&lt;A&gt; pAutoA(pA);
  container.push_back(boost::bind(&amp;SomeClass::HandleA, this, pAutoA);
  </code></pre>
  
  <p>doesn't compile (see <a href="http://lists.boost.org/Archives/boost/2002/10/38652.php" rel="noreferrer">here</a>)</p>
  
  <pre><code>auto_ptr&lt;A&gt; pAutoA(pA);
  container.push_back(boost::bind(&amp;SomeClass::HandleA, this, boost::ref(pAutoA));
  </code></pre>
  
  <p>pAutoA is destroyed, deleting underlying pA.</p>
  
  <p><strong>EDIT 02</strong></p>
  
  <p>In the mentioned container I will need to store misc "callbacks" with different arguments. Some of them are raw pointers to object. Since the code is old, I not always can change it.</p>
  
  <p>Writing own wrapper for storing callbacks in container is last resort (while maybe the only one), hence bounty.</p>