This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: auto_ptr bug


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/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]