Thread View: comp.std.c++
1 messages
1 total messages
Started by veldhuis
Mon, 11 Sep 1995 19:10
Re: Implementing auto_ptr
Author: veldhuis
Date: Mon, 11 Sep 1995 19:10
Date: Mon, 11 Sep 1995 19:10
31 lines
1586 bytes
1586 bytes
:>- Why does 'operator=(auto_ptr&)' return a 'void' instead of the common
:> idiom to return a reference to the LHS: 'return *this'?
See also an earlier message of me. I think the assignment kills the right
hand side of an expression, so when it returns a copy and assigns that to
another auto_ptr it will also be invalid. It is possible I misunderstood the
message of Scott, but to me it seemed that
SM> template<class T>
SM> inline void auto_ptr<T>::operator=(auto_ptr<T>& rhs)
SM> { if (this != &rhs) reset(rhs.release()); }
releases the memory from the rhs instance, therefore
a = b = c will release memory from b and c and make the statement do
something else as we expect. I just hope I am wrong here.
with regards,
Wim Veldhuis
---------------------------------------------------
| Written with NeoLogic News for OS/2 |
---------------------------------------------------
| Unregistered copy with 10 days of use remaining |
---------------------------------------------------
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads