std::auto_ptr lacks const copy constructor, therefore I cannot use it directly in collections. is there some way to have for example vector of std::auto_ptr without using boost pointer collection template?
If you have a C++0x compiler you can use shared_ptr
or unique_ptr
as appropriate.
There is a good example of correct unique_ptr
usage here courtesy of @James McNellis. For a shared_ptr
walkthrough look here, courtesy of @D.Shawley. [Upvotes would still be appreciated on those threads, I am sure.]
vector
of auto_ptr
is always invalid, although Visual C++ v6 disagreed.