Article View: comp.std.c++
Article #3296Re: Cleaning auto_ptr copy semantics.
From: Ken Walter
Date: Tue, 06 Feb 1996 20:59
Date: Tue, 06 Feb 1996 20:59
29 lines
1890 bytes
1890 bytes
In message <AUSTERN.96Feb5113807@isolde.mti.sgi.com> - austern@isolde.mti.sgi.c om (Matt Austern) writes: [...] :>:>This leads to an interesting question: given the (current or proposed) :>semantics of auto_ptr<X>, how many situations can you think of where :>it is actually useful and correct to transfer ownership from one :>auto_ptr to another? [...] We pass ownership of objects around. In C you had to "know" if ownership was passed to know who was responsible for the object. auto_ptrs with copy and assignment seem fine to me. You only do it when you are passing ownership. As a parameter I would pass the actual pointer or a ref rather than the autoptr if I expected to retain ownership. On return values it means than the caller is receiving ownership of an object. You still can have the dangling reference problem, but if that is important (I rarely see it in my environment) you use reference counted pointers. Ken Walter * All the above is hearsay and the opinion of nobody in particular [ 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://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
Technical Details
Message-ID:
<4f8djf$1jja@news.gate.net>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageReferences:
<01BAF15D.08B8EEE0@dino.int.com> <31153AC5.1776@suphys.physics.su.oz.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: solution@gate.net (Ken Walter) Newsgroups: comp.std.c++ Subject: Re: Cleaning auto_ptr copy semantics. Date: 6 Feb 1996 20:59:39 GMT Organization: Solution Technology Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <4f8djf$1jja@news.gate.net> References: <01BAF15D.08B8EEE0@dino.int.com> <31153AC5.1776@suphys.physics.su.oz.au> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: dfbfl2-53.gate.net X-Newsreader: NeoLogic News for OS/2 [version: 4.2] Content-Length: 1016 X-Lines: 24 Originator: clamage@taumet