Jump to content
  • Advertisement
Sign in to follow this  
wasd

Reference to std::list data

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

If I store a reference to something in a std::list, is it guaranteed to remain valid while the object is in the list?

Share this post


Link to post
Share on other sites
Advertisement
References, pointers and iterators to objects in a std::list are guaranteed to stay valid as long as the element isn't delete from the list (or the list is destroyed, etc.).

Share this post


Link to post
Share on other sites
Wait, hold on. Do you mean (store a reference) (to) (something in a std::list), or (store) (a reference to something) (in a std::list)? Because I'm pretty sure the latter (i.e. making a std::list of references-to-T) isn't valid in the first place. (Although I imagine the compiler should be able to catch something like that...)

Share this post


Link to post
Share on other sites
Sorry, yeah, I meant (store a reference)(to)(something in a std::list). Thanks for the replies

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!