c++ - how to cast void* to shared_ptr<mytype> -
i have problem opengl project, converting void*
pointer shared_ptr<mytype>
.
i using bullet set pointers on rigid body with:
root_physics->rigidbody->setuserpointer(&this->root_directory->handle);
the handle of type shared_ptr<mytype>
.
the void*
pointer returned bullet's library function, getuserpointer()
:
raycallback.m_collisionobject->getuserpointer()
to convert mytype
, static_cast
not working:
std::shared_ptr<disk_node> u_poi = static_cast< std::shared_ptr<disk_node> >( raycallback.m_collisionobject->getuserpointer() );
the error, @ compilation time:
/usr/include/c++/4.8/bits/shared_ptr_base.h:739:39: error: invalid conversion ‘void*’ ‘mytype*’ [-fpermissive]
any idea how can convert void*
returned getuserpointer()
shared_ptr<mytype>
?
since storing pointer instance of std::shared_ptr
need cast value returned getuserpointer
std::shared_ptr<>*
instead of std::shared_ptr<>
.
std::shared_ptr<disk_node>* u_poi = static_cast< std::shared_ptr<disk_node>* >(raycallback.m_collisionobject->getuserpointer());
Comments
Post a Comment