Boost logo

Boost :

From: Ed Brey (brey_at_[hidden])
Date: 1999-12-06 09:48:53


"Moore, Paul" wrote:
>
> One other type, which never comes up, but which I have found useful, is a
> simple noncopyable pointer (my needs were only for an "optional" version, to
> use your terminology).
>
> To elaborate, I had a data structure full of pointers. Like a good boy, I
> decided to use refcounted pointers, to make sure I didn't leak memory.
>
> But when I analysed what I had done, it dawned on me that I was never
> copying pointers after creation. So the reference counts never got above
> 1... For this type of situation, reference counting is overkill. How about
> just having an auto_pointer type (delete-on-destructor semantics) but with
> copying prohibited. This would trap any erroneous attempts to share
> pointers, and provide auto-deletion, at minimal cost.

A referenced counted pointer where the reference count never goes
above 1 sounds to me like a scoped_ptr. Is there difference between
scoped_ptr and what you are thinking of?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk