This is the mail archive of the libstdc++@gcc.gnu.org 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]
Other format: [Raw text]

auto_ptr problems


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


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