Sign in to follow this  
Sir Sapo

boost::shared_ptr question

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this