Article View: comp.std.c++
Article #2149Re: auto_ptr: :reset and auto_ptr::operator=
From: Dag Bruck
Date: Mon, 09 Oct 1995 09:40
Date: Mon, 09 Oct 1995 09:40
42 lines
2129 bytes
2129 bytes
J. Kanze <kanze@gabi-soft.fr> wrote:
>
>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?
The answer is simple, but perhaps not acceptable: you would have to return
values through a reference argument.
Alternatively, you need a helper class, something like:
template <class T>
struct auto_ptr_value {
operator auto_ptr<T> ();
auto_ptr_value(const auto_ptr_value &);
private:
// .....
};
template <class T>
auto_ptr_value<T> auto_ptr<T>::make_copy()
{
// create auto_ptr_value somehow
}
Is it worth it?
Dag Bruck
--
Dynasim AB Phone: +46 46 182500
Research Park Ideon Fax: +46 46 129879
S-223 70 Lund E-mail: Dag@Dynasim.se
Sweden URL: http://www.dynasim.se
---
[ 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:
<DG6Apt.2CK@akropolis.malmo.trab.se>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<199509111753.AA15077@xs1.xs4all.nl> <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!in1.uu.net!bounce-back Date: 09 Oct 95 09:40:15 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ From: dag@net.dynasim.se (Dag Bruck) Subject: Re: auto_ptr: :reset and auto_ptr::operator= Message-ID: <DG6Apt.2CK@akropolis.malmo.trab.se> Sender: news@akropolis.malmo.trab.se (News adm) Organization: Dynasim AB, Lund, Sweden References: <199509111753.AA15077@xs1.xs4all.nl> <9510022022.AA18434@mailserv.taligent.com> <DFv3F0.DCr@akropolis.malmo.trab.se> <44thrj$kid@gabi.gabi-soft.fr> X-Original-Date: Mon, 9 Oct 1995 08:39:29 GMT Content-Type: text Content-Length: 1071 Apparently-To: comp-std-c++@cis.ohio-state.edu X-Auth: PGPMoose V1.0 PGP comp.std.c++ iQBFAgUBMHjuD+EDnX0m9pzZAQFo4QGAhOUP/6nDGWoiKK3Kabn3N4A3y5rM2bjW 5vDsyiU52Ib6FNWuSjXaYI3QRI+8GtEq =pAmU