Jump to content
  • Advertisement
Sign in to follow this  
Sir Sapo

boost::shared_ptr question

This topic is 4322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone, Just a quick question about using shared pointers. If I reassign a shared_ptr point to something else, and the reference count of the previously pointed to object is 0, will the shared_ptr automatically delete the old pointer when the shared_ptr is reassigned somewhere else? Sorry if that's unclear...

Share this post


Link to post
Share on other sites
Advertisement
When the last shared_ptr to a bunch of memory is either destroyed or realigned, the reference count drops from 1 to 0 (I believe), and the memory is deallocated. It is a fairly typical shared pointer way of handling things.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!