Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-12-29 01:02:45

"Dan W." <danw_at_[hidden]> wrote in message

> I just thought of another situation where where smart pointer input might
> be useful. Say I want two or more pointer containers to share ownership of
> some of the pointed to elements...

sounds like you need a reference counted smart pointer.

> Example: A 3D game-engine where I keep objects into sorted containers
> X, Y and Z coordinates. Or to make it more complex (and more realistic a
> situation) where I have multiple overlapping containers along each of the
> axes, where the multiple containers handle distinct orders of distance,
> inversely proportional levels of detail. I may not want an object to be
> deleted until it has been dropped from all containers.

manually handling this seems to me as to be begging for trouple. I have some
 graphics background myself (see and the scene
tree package
used an intrusive_ptr reference counted smart pointer.

It would be extreamely interesting to see if the pointer containers could be
in scene trees. However, I don't know enough about this to say so. Ownership
are definitely a problem; Overlapping containers might be emulated by
keeping a reference
to the pointer container with the overlapping elements; perhaps one should
use a shared_ptr< ptr_container<> >. ?

> Also, with
> boost::shared_ptr I can supply an alternate deleter functor. I haven't
> looked at your code very deeply yet, is there a similar capability built
> in, or would you consider it doable or useful?

Of course it is doable, I just don't see what purpose it has.



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