12.07.2015 Views

dangling pointer

dangling pointer

dangling pointer

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

oost::weak_ptr Creation and ResettingA boost::weak_ptr must be created from a boost::shared_ptr.boost::shared_ptr sp1(new X);// Construct a weak <strong>pointer</strong> that observes what sp points toboost::weak_ptr wp1(sp1);//// Alternatively, use assignmentboost::weak_ptr wp2; // null weak <strong>pointer</strong>wp2 = sp1;// A weak <strong>pointer</strong> can be reset to null:wp1.reset(); // Equivalent to wp1 = weak_ptr();// There is no reset that takes a weak <strong>pointer</strong> or shared// <strong>pointer</strong> as an argument. Use assignment instead:boost::shared_ptr sp2(new X);wp1 = sp2;wp2 = wp1;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!