[LC++]STL and auto_ptr woes
Vincent.Penquerch at artworks.co.uk
Thu Mar 7 03:01:05 UTC 2002
> I don't think that auto_ptr<> supports the assignment
> operator--it only
> supports initialization via the constructor. That's why it
> won't work in
> your scenario.
> Is auto_ptr<> supposed to work in a Standard C++ Library
> collection? I seem
> to recall this as being a no-no, but I don't have the book in
> front of me
> right now.
I think you answered your own question. I vaguely remembered
that auto_ptr is an STL collection would fail because of
ownership issues when being copied (auto_ptr, IIRC, transfers
ownership when assigned, so it does not actually duplicate
but gives (mv rather than cp), so the original collection
will now hold invalid data). That's what I think I remember,
I think I got the actual fully explained reason in one of
Scott Meyer's books, but it's quite fuzzy now, so I could be
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the tuxCPProgramming