This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: auto_ptr bug
- To: libstdc++ at sourceware dot cygnus dot com
- Subject: Re: auto_ptr bug
- From: "Marc A. Lepage" <mlepage at molecularmining dot com>
- Date: Mon, 10 Apr 2000 14:34:38 -0400
- Organization: Molecular Mining Corporation
- References: <Pine.LNX.4.21.0004101416230.18867-100000@spud.laurelnetworks.c>
bgarcia@laurelnetworks.com wrote:
>
> From libstc++ 2.90.8, bits/std_memory.h:
>
> -----------------------------------------------------------------------------
> template <class _Tp> class auto_ptr {
> private:
> _Tp* _M_ptr;
>
> public:
> ...
> auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {}
>
> -----------------------------------------------------------------------------
>
> Shouldn't that constructor take a "const auto_ptr&" ?
> (therefore, release() should be const, and _M_ptr will probably need to
> be made mutable).
No. Copying an auto_ptr changes the original (it has to release
ownership).
> Among other things, the current interface means that you can't currently
> insert an entry into an stl map full of auto_ptr's (try it).
You cannot use auto_ptrs in standard containers. It is expressly
forbidden and designed to not work.
--
Marc A. Lepage
Software Developer
Molecular Mining Corporation
http://www.molecularmining.com/