title: how to cast void* to shared_ptr<mytype>
body: <p>I have a problem with an OpenGL project, converting from a <code>void*</code> pointer to a <code>shared_ptr&lt;mytype&gt;</code>.</p>
  
  <p>I am using Bullet to set pointers on the rigid body with:</p>
  
  <pre><code>root_physics-&gt;rigidBody-&gt;setUserPointer(&amp;this-&gt;root_directory-&gt;handle);
  </code></pre>
  
  <p>The handle is of type <code>shared_ptr&lt;mytype&gt;</code>.</p>
  
  <p>The <code>void*</code> pointer is returned by Bullet's library function, <code>getUserPointer()</code>:</p>
  
  <pre><code>RayCallback.m_collisionObject-&gt;getUserPointer()
  </code></pre>
  
  <p>To convert back to <code>mytype</code>, <code>static_cast</code> is not working:</p>
  
  <pre><code>std::shared_ptr&lt;disk_node&gt; u_poi = static_cast&lt; std::shared_ptr&lt;disk_node&gt; &gt;( RayCallback.m_collisionObject-&gt;getUserPointer() );
  </code></pre>
  
  <p>The error, at compilation time:</p>
  
  <pre><code>/usr/include/c++/4.8/bits/shared_ptr_base.h:739:39: error: invalid conversion from ‘void*’ to ‘mytype*’ [-fpermissive]
  </code></pre>
  
  <p>Any idea how I can convert from the <code>void*</code> returned by <code>getUserPointer()</code> to <code>shared_ptr&lt;mytype&gt;</code>?</p>