title: Getting shared_ptr for "this" object to another function : giving run time exception
body: <p>Actually I want to extract shared_ptr from 'this' object in an another function.
  For the same suppose we have a situation where a "Thing member function" needs to pass a pointer to "this" object to another function like:</p>
  
  <pre><code>#include "stdafx.h"
  
  #include&lt;memory&gt;
  
  using namespace std;
  
  
  class Thing {
  public:
   void foo();
   void defrangulate();
  };
  void Thing::defrangulate()
  {
  }
  
  void transformIt(shared_ptr&lt;Thing&gt; ptr)
  {
   ptr-&gt;defrangulate();
   /* etc. */
  }
  
  void Thing::foo()
  {
   // we need to transformIt this object
   shared_ptr&lt;Thing&gt; sp_for_this(this);
   transformIt(sp_for_this);
  }
  
  int main()
  {
   shared_ptr&lt;Thing&gt; t1(new Thing);// start a manager object for the Thing
   t1-&gt;foo();
  }
  </code></pre>
  
  <p>output:
  Debug Assertion failed!
  Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)</p>
  
  <p>Am I doing any mistake which causing this run time exception ? </p>