Sign in to follow this  
Silex

STL container that works like vector of pointers?

Recommended Posts

Silex    140
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
SiCrane    11839
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
JohnBolton    1372
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

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