title: Getting a boost::shared_ptr for this
body: <p>I am making extensive use of <code>boost:shared_ptr</code> in my code. In fact, most of the objects that are allocated on the heap are held by a <code>shared_ptr</code>. Unfortunately this means that I can't pass <code>this</code> into any function that takes a <code>shared_ptr</code>. Consider this code:</p>
  
  <pre><code>void bar(boost::shared_ptr&lt;Foo&gt; pFoo)
  {
      ...
  }
  
  void Foo::someFunction()
  {
      bar(this);
  }
  </code></pre>
  
  <p>There are two problems here.  First, this won't compile because the T* constructor for <code>shared_ptr</code> is explicit. Second, if I force it to build with <code>bar(boost::shared_ptr&lt;Foo&gt;(this))</code> I will have created a second shared pointer to my object that will eventually lead to a double-delete.</p>
  
  <p>This brings me to my question: Is there any standard pattern for getting a copy of the existing shared pointer you know exists from inside a method on one of those objects?  Is using intrusive reference counting my only option here?</p>