c++ - how to convert a boost::weak_ptr to a boost::shared_ptr -
i have shared_ptr , weak_ptr
typedef boost::weak_ptr<classname> classnameptr; typedef boost::shared_ptr<x> xptr;
how convert weak_ptr shared_ptr
shared_ptr = weak_ptr; xptr = classnameptr; ?????
as said
boost::shared_ptr<type> ptr = weak_ptr.lock();
if not want exception or use cast constructor
boost::shared_ptr<type> ptr(weak_ptr);
this throw if weak pointer deleted.
Comments
Post a Comment