Article View: comp.std.c++
Article #3042Re: auto_ptr again
From: austern Matt Austern
Date: Thu, 18 Jan 1996 19:00
Date: Thu, 18 Jan 1996 19:00
32 lines
2387 bytes
2387 bytes
In article <4djrn4$js1@engnews1.Eng.Sun.COM> clamage@Eng.Sun.COM (Steve Clamage) writes: > That point has been beaten to death in the C++ committee and also in > this forum. Some people felt an auto_ptr should be able to have multiple > owners, but people with experience with this kind of design persuaded > the committee that auto_ptrs are too hard to use unless they can have > only a single owner. Thus, ownership is transferred upon copying. > > That is, single ownership is a deliberate design decision based on the > semantics an auto-ptr should have. It is not an implementation issue. I thought it was generally agreed that auto_ptrs as currently defined were broken---specifically, that the semantics of strict ownership, constness, and the binding of temporary objects, ended up making an auto_ptr nearly useless for returning a value from a function. That's unfortunate, since returning something from a function is one of the situations when it's most important to have some safe wrapper class like auto_ptr. I've spent a bit of time trying to come up with bright ideas for fixing auto_ptr, but I don't really have any. Reference-counted pointers don't have this particular problem, though, and that might be the best argument for putting rc_ptr in the standard in addition to (or instead of) auto_ptr. -- Matt Austern SGI: MTI Compilers Group austern@isolde.mti.sgi.com --- [ 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:
<AUSTERN.96Jan18103535@isolde.mti.sgi.com>Path:
arc1-ca.pugleaf.net!fido.asd.sgi.com!austernReferences:
<ADxYD_mKQD@qsar.chem.msu.su> <4djrn4$js1@engnews1.Eng.Sun.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern From: austern (Matt Austern) Newsgroups: comp.std.c++ Subject: Re: auto_ptr again Date: 18 Jan 1996 11:00:55 PST Organization: SGI Approved: austern@isolde.mti.sgi.com Message-ID: <AUSTERN.96Jan18103535@isolde.mti.sgi.com> References: <ADxYD_mKQD@qsar.chem.msu.su> <4djrn4$js1@engnews1.Eng.Sun.COM> Reply-To: austern@mti.mti.sgi.com NNTP-Posting-Host: isolde.mti.sgi.com X-Original-Date: 18 Jan 1996 18:35:35 GMT In-Reply-To: clamage@Eng.Sun.COM's message of 18 Jan 96 02:38:07 GMT X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBMP6ZAUy4NqrwXLNJAQGd9QIAgYBzVXnrAsLoepaBDAkHP/njA1KW4DpU UjTP06pcBGNCRg38jr97ZCaIyBZlq/y4kq2gR2OztmUcCyKKtJ4Bog== =QR35 Originator: austern@isolde.mti.sgi.com