auto_ptr problems
Jack Reeves
jackw_reeves@hotmail.com
Tue Jul 2 11:37:00 GMT 2002
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
More information about the Libstdc++
mailing list