Sign in to follow this  

static smart pointers

This topic is 4358 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

Guest Anonymous Poster
Quote:
Original post by JohnBolton
They get released after main() exits.


Thank you. So, they should still be safe? Is there an order of releasing by module? What if I have a static smartpointer that points to an object created in another module, could that object be released when the other module unloads before the smartpointer is released?

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Is there an order of releasing by module? What if I have a static smartpointer that points to an object created in another module, could that object be released when the other module unloads before the smartpointer is released?


Like the order of construction, the order of module destruction should be considered as random. It should be ok because this is something that smart pointers are designed to deal with, but I guess it depends on what kind of smart pointer you have. One notable exception is a smart pointer to a COM object.

Share this post


Link to post
Share on other sites
You do have some guarantees, like static objects with dynamic initialization defined in the same translation unit will be created in the order they are defined and destroyed in the reverse order. However, the guarantees aren't that useful in the general case.

Share this post


Link to post
Share on other sites

This topic is 4358 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.

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