Jump to content
  • Advertisement
Sign in to follow this  
all_names_taken

STL containers scope and copy questions

This topic is 4006 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 use the public functions to add and remove elements (assuming the elements are objects or variables but not pointers or references) and otherwise manipulate any STL container, what is correct below: - can I expect the content inside the container to remain allocated for as long as the container is in scope, even if the variable I added from went out of scope? - can I expect the contents I returned from a container item retrieve call, and assigned to a variable (i.e. not a reference), to remain allocated for as long as the variable is in scope, even if the STL container is not? - does STL perform a lot of copying or calls to assignment operator and/or copy constructor during inserts, removes and other operations? Say, if I put in an object with some 100 kb static data, will it be copied during an insert operation? If I put in an object with some 100 kb mostly dynamic data, will my custom copy constructor that copies all that data be executed and that data still be copied during an insert operation?

Share this post


Link to post
Share on other sites
Advertisement
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!