Topic: class auto_ptr ( Was: A RFC for YAAC++ )


Author: tob@world.std.com (Tom O Breton)
Date: Wed, 28 Dec 1994 07:01:51 GMT
Raw View
beman@dawes.win.net (Beman Dawes) writes:
> For example, here is a portion of Greg Colvin's
> proposal ANSI X3J16/94-0202R1, ISO WG21/N0589R1 currently being
> considered by the committee:

>       public:
>       [...]
>       X* release();
>       [...]



> Expression           Value              Effect
>       [...]
> a.release()          a.px               a.px = 0

(I realize this is Colvin's proposal, not yours)

Shouldn't release() be private? Or not be a function at all, only exist
as part of the copy ctor & assignment operator? Making it public invites
memory leaks.

It could also stand to have a clone method:

Expression           Effect
a.clone( d )         a.px = new X( *d.px )

        Tom

--
tob@world.std.com
TomBreton@delphi.com: Author of The Burning Tower





Author: modena@netcom.com (Modena Software)
Date: Wed, 28 Dec 1994 08:15:44 GMT
Raw View
In article <D1IE73.GvB@world.std.com> tob@world.std.com writes:
>beman@dawes.win.net (Beman Dawes) writes:
>> For example, here is a portion of Greg Colvin's
>> proposal ANSI X3J16/94-0202R1, ISO WG21/N0589R1 currently being
>> considered by the committee:
>
>>       public:
>>       [...]
>>       X* release();
>>       [...]
>
>
>
>> Expression           Value              Effect
>>       [...]
>> a.release()          a.px               a.px = 0
>
>(I realize this is Colvin's proposal, not yours)
>
>Shouldn't release() be private? Or not be a function at all, only exist
>as part of the copy ctor & assignment operator? Making it public invites
>memory leaks.

release() is expected to release the memory so it won't lead to
memory leaks.
Also note that the copy ctor & assignment operator are private
to prevent premature deletions.


-- Kalyan
Modena Software, Inc