🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13784

Re: std::auto_ptr<> Help Please

#13784
From: Harold Howe [TeamB]
Date: Fri, 12 Sep 2003 21:42
22 lines
1823 bytes
> This is a very interesting usage of auto_ptr which I have not seen before,
> or considered.  What is the lifetime of such an object (when does it go out
> of scope)?  

When the object to which it belongs is destoyed. Specifically

TForm1::~TForm1()
{

}  --> right here, after the body of ~TForm1 has run, but before any 
base class destructors run.

Not only is this nifty, it is almost the only way to write memory safe 
code if the constructor can throw exceptions.

> If so, this is much preferred over having to remember to delete the
> object in the class' destructor.

I would say yes. See Herb Sutter's Exception C++ and More Exceptional C++.

H^2
Technical Details
Message-ID: <3f623db2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3F5E64B4.4050201@NetScape.net> <3F5E6A0C.6000601@anonymous_one.com> <3f5e7991$1@newsgroups.borland.com> <3f5eaa60$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,da48c8ace4f19025
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-09-12 14:52:39 PST
Date: Fri, 12 Sep 2003 16:42:31 -0500
From: "Harold Howe [TeamB]" <hhowe@bcbdev.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030901 Thunderbird/0.2
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: std::auto_ptr<> Help Please
References: <3F5E64B4.4050201@NetScape.net> <3F5E6A0C.6000601@anonymous_one.com> <3f5e7991$1@newsgroups.borland.com> <3f5eaa60$1@newsgroups.borland.com>
In-Reply-To: <3f5eaa60$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 66.43.209.135
Message-ID: <3f623db2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1063402930 66.43.209.135 (12 Sep 2003 14:42:10 -0700)
Lines: 23
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail