• Advertisement
Sign in to follow this  

containers and auto_ptr

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

I know that you shouldn't put auto_ptr-like smart-pointers in STL containers because the containers aren't gauranteed by the standard not to make internal copies (which would, of course, screw up whatever they are making internal copies of). Now, if I want destructive-copy smart-pointers (like auto_ptr), do I have to make my own containers!? Is there a way around this weirdness?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by thedevdan
Thanks for telling me what I didn't want to hear.


I aim to please.

Share this post


Link to post
Share on other sites
What are you using them for? Maybe boost::shared_ptr would do the trick. It allows you to keep several shared pointers to an object and when all the pointers go out of scope the object gets deleted.

Share this post


Link to post
Share on other sites
Use boost::shared_ptr instead (since it was designed for just that purpose); IIRC it's set to be included in the C++ standard, so you'll be ahead of the curve.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Why not just allocate an auto_ptr on the heap? ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement