From: Dan W. (danw_at_[hidden])
Date: 2003-12-29 00:31:13
Sorry to post as new thread, I still haven't figured out how to reply to a
>> Would it be safer for push_back(), say, to take a smart pointer as input?
>in some sense yes. You're thinking about giving the user a hint about the
>ownership semantics. However,
>since the user could also pass the address of a stack object to the smart
>pointer, we have only
>moved the problem. Knowing that the containers take ownership is really
>neccesary to use the containers
>properly; we can't protect against malice.
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...
Example: A 3D game-engine where I keep objects into sorted containers along
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, and
inversely proportional levels of detail. I may not want an object to be
deleted until it has been dropped from all containers. 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?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk