Jump to content
  • Advertisement
Sign in to follow this  
Raeldor

static smart pointers

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

Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!