🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: auto_ptr: :reset and auto_ptr::operator=

#2135
From: Colin Chambers
Date: Fri, 06 Oct 1995 15:03
32 lines
1961 bytes
In article: <44thrj$kid@gabi.gabi-soft.fr>  kanze@gabi-soft.fr (J. Kanze) writes:
> Dag Bruck (dag@net.dynasim.se) wrote:
> |> Because of the confusion, op= and the copy-ctor should be unimplemented
> |> (private) and the transfer of ownership implemented with some other
> |> function.  (This is also one of the Swedish Committee Draft Ballot
> |> comments.)
> 
> So how do you handle transfer of ownership in return values?
> 

If op= and the copy-ctor are unimplemented then it is probably inappropriate
to have a function that returns an auto_ptr<>.  It seems to me that this is not
a great loss as the same end result can still be achieved, albeit with different syntax,
by using a (possibly const) auto_ptr<> reference or pointer argument.  For example

	void f(auto_ptr<T>& p) { p.reset(new T); }

	void g()
	{
		auto_ptr<T> p;
		f(p);
		...
	}
	
-- 
Colin Chambers
cc@lagan.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: <188686914wnr@lagan.com>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
References: <199509111753.AA15077@xs1.xs4all.nl> <MATT.95Sep22101332@physics11.Berkeley.EDU> <9527400.19710@mulga.cs.mu.OZ.AU> <9510022022.AA18434@mailserv.taligent.com> <DFv3F0.DCr@akropolis.malmo.trab.se> <44thrj$kid@gabi.gabi-soft.fr>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: Colin Chambers <cc@lagan.com>
Newsgroups: comp.std.c++
Subject: Re: auto_ptr: :reset and auto_ptr::operator=
Date: 6 Oct 1995 15:03:54 GMT
Organization: Lagan Technologies Ltd
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <188686914wnr@lagan.com>
References: <199509111753.AA15077@xs1.xs4all.nl> <MATT.95Sep22101332@physics11.Berkeley.EDU> <9527400.19710@mulga.cs.mu.OZ.AU> <9510022022.AA18434@mailserv.taligent.com> <DFv3F0.DCr@akropolis.malmo.trab.se> <44thrj$kid@gabi.gabi-soft.fr>
Reply-To: cc@lagan.com
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: laganadm.demon.co.uk
X-Broken-Date: Thursday, Oct 05, 1995 16.47.24
X-Newsreader: Newswin Alpha 0.7
Content-Length: 887
X-Lines: 28
Originator: clamage@taumet