Boost logo

Boost :

From: Moore, Paul (Paul.Moore_at_[hidden])
Date: 1999-12-06 04:25:28

From: Darin Adler [mailto:darin_at_[hidden]]
> * or -> is legal. Because of these goals, I'd like these
> kinds of smart pointers:
> 1) strong pointer -- The holder of this pointer owns the
> 2) weak pointer -- The holder of this pointer knows the
> 3) optional strong pointer -- This can hold a strong
> 4) optional weak pointer -- This can hold a weak pointer

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.

Thoughts, anyone?

Paul Moore

Boost list run by bdawes at, gregod at, cpdaniel at, john at