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

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -