Sign in to follow this  

STL container that works like vector of pointers?

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

Hi, Is there an STL container class that works like a vector of pointers to avoid creating copies during sorting and re-arranging of the array? I suppose it's easy enough to just write vector<object*> and call delete on the objects manually, just wondering if there was somethign that encapsulated that functionality alreaedy... Thanks!

Share this post


Link to post
Share on other sites
And you can also use a container of smart pointers like boost::shared_ptr<> if boost::ptr_vector isn't quite right for your needs.

Share this post


Link to post
Share on other sites
If your goal is avoid creating copies, then the best solution is probably a container of pointers, but if your goal is both fast sorting and random access, then std::map might be the best compromise.

Share this post


Link to post
Share on other sites

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