🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1945

Re: Implementing auto_ptr

#1945
From: veldhuis
Date: Mon, 11 Sep 1995 19:10
31 lines
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. ]
Technical Details
Message-ID: <MATT.95Sep11121011@physics2.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!128.32.155.1!matt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt
From: veldhuis@xs4all.nl
Newsgroups: comp.std.c++
Subject: Re: Implementing auto_ptr
Date: 11 Sep 1995 19:10:10 GMT
Organization: <none>
Approved: matt@physics2.Berkeley.EDU (Matt Austern)
Message-ID: <MATT.95Sep11121011@physics2.Berkeley.EDU>
NNTP-Posting-Host: physics2.berkeley.edu