This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
auto_ptr problems
- From: "Jack Reeves" <jackw_reeves at hotmail dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 02 Jul 2002 18:37:40 +0000
- Subject: auto_ptr problems
- Bcc:
- Reply-to: jack_reeves at bleading-edge dot com
The following works and shouldn't
#include <memory>
struct Base {};
int main() {
std::auto_ptr<Base> ptr;
ptr = new Base;
}
the following doesn't and should
#include <memory>
struct Base {};
struct Derived : public Base {};
std::auto_ptr<Derived> foo() {
return std::auto_ptr<Derived>(new Derived);
}
int main() {
std::auto_ptr<Base> ptr;
ptr = foo();
}
here is the fix for both
File: std/std_memory.h
124c124
< auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {}
---
explicit auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {}
196c196
< { return auto_ptr_ref<_Tp>(this->release()); }
---
{ return auto_ptr_ref<_Tp1>(this->release()); }
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com