🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: sample auto_ptr template

#4040
From: Pulkkinen Esa
Date: Mon, 15 Apr 1996 16:36
41 lines
2545 bytes
>In article <4kjcvb$ghf@ugress.uib.no> boukanov@sentef1.fi.uib.no (Igor
>Boukanov) writes:
>|> auto_ptr<T>(const auto_ptr<T>&) to auto_ptr<T>(auto_ptr<T>&)
>|> and 
>|> auto_ptr<T>& operator=(const auto_ptr<T>&) to
>|> auto_ptr<T>& operator=(auto_ptr<T>&)

IMHO, copy constructors for auto_ptr must be either private or
have non-const parameters.

In article <KANZE.96Apr12130738@gabi.gabi-soft.fr>,
J. Kanze <kanze@gabi-soft.fr> wrote:
>We've been through all this before.  That was the original version.
>Regretfully, makes it impossible to return an auto_ptr from a function.
>And one of the more frequent uses of auto_ptr involves returning them
>from functions.

I can't really understand, why it should be possible to return
auto_ptr's from functions - why not define a distinct pointer type
for that purpose - and define conversion from auto_ptr to
that pointer type for returning it from functions. That is - 
to return an auto_ptr from functions, you write:

  taligent_ptr<T> f() 
  { auto_ptr<T> p=new T;
    return p;
  }

(I have no idea if the 'taligent_ptr' is suitable for this kind of thing,
but its name is as good as any for this example .... )
-- 
   Esa Pulkkinen                        | C++ programmers do it virtually
   E-Mail:  esap@cs.tut.fi              | everywhere with a class, resulting
   WWW   :  http://www.cs.tut.fi/~esap/ | in multiple inheritance.
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]
Technical Details
Message-ID: <4kop9s$d8l@peippo.cs.tut.fi>
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern
References: <009A0A5CE1159CC0.49802F14@ittpub.nl> <gregorDpoGM2.Hw2@netcom.com> <4kjcvb$ghf@ugress.uib.no> <KANZE.96Apr12130738@gabi.gabi-soft.fr>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern
From: esap@cs.tut.fi (Pulkkinen Esa)
Newsgroups: comp.std.c++
Subject: Re: sample auto_ptr template
Date: 15 Apr 1996 09:36:01 PDT
Organization: Tampere University of Technology
Approved: austern@isolde.mti.sgi.com
Message-ID: <4kop9s$d8l@peippo.cs.tut.fi>
References: <009A0A5CE1159CC0.49802F14@ittpub.nl> <gregorDpoGM2.Hw2@netcom.com> <4kjcvb$ghf@ugress.uib.no> <KANZE.96Apr12130738@gabi.gabi-soft.fr>
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: 13 Apr 1996 17:46:36 GMT
NNTP-Posting-User: esap
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMXJ68ky4NqrwXLNJAQFzSQIAogLRJWVHxYA8wUYHbvcpbs3Vgcq5vkdW
 xhtsmHViBAfbKbWPL2lLjoF3YqY3Si6ua2gLbkGMX4A1mfB7RbgwSw==
 =Zv/9
Originator: austern@isolde.mti.sgi.com