containers and auto_ptr
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?
No, there is no way around it. STL Container elements must be Assignable.
Destructive copy violates that requirement.
Destructive copy violates that requirement.
Quote:Original post by thedevdan
Thanks for telling me what I didn't want to hear.
I aim to please.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement