title: How to combine the use of std::bind with std::shared_ptr
body: <p>I need to do something like this more than often:</p>
  
  <pre><code>AsyncOperation * pAsyncOperation = new AsyncOperation();
  auto bindOperation = std::bind(&amp;AsyncOperation::operator(), std::ref(*pAsyncOperation));
  std::thread thread(bindOperation );
  thread.join();
  </code></pre>
  
  <p>with <code>AsyncOperation</code> being any custom class implementing <code>operator()</code> <em>(also known as function object)</em>. </p>
  
  <p>Is it possible to indicate to the <code>std::bind</code> to use a <code>std::shared_ptr</code> instead of a <code>std::ref</code> ?
  This would prevent memory leaks, without my needing to keep a reference on <code>pAsyncOperation</code>, and would delete the <code>AsyncOperation</code> automatically at the end of the thread, that is the end of this asynchronous task.</p>
  
  <p>EDIT: I don't always have access to std::thread, the thread library can be boost::thread or even any other platform dependent threads. And by consequence, not access to std::async.</p>
  
  <p>My main issue is to have a notion of ownership in the std::bind.</p>