From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-07-25 16:00:20
From: "Philip Nash" <philip.nash_at_[hidden]>
> I suggested in a branch from the earlier thread that maybe the "finalizer"
> function, as you put it, would best be served by a separate class (or set
> classes - one for shared one for basic scoped) that are tailored for true
> "initialisation is resource aquisition" needs.
> This could also contain non pointer types.
> My proposal is for:
> shared_resource<T> and
This would be an useful generalization, but it goes beyond what I was trying
to do - stay within the shared_ptr<> already established interface and, as a
quality of implementation issue, make it handle the different heap managers
problem and provide a dynamic_cast-like facility.
It turns out that to accomplish this the shared_ptr has to store a finalizer
function anyway, so it was easy to expose; but whether this feature will
become officially part of shared_ptr's interface remains to be determined.
If you are interested in generalizing shared_ptr into shared_resource, note
that the updated detail/shared_count.hpp can handle any type and not just
pointers, so you would be able to build on that.
Writing the code for a shared_resource<> is the easy part -- it's mainly
about deleting the irrelevant stuff from shared_ptr. The hard part is
specifying semantics, writing the documentation and writing a robust test.
:-) [For me at least.]
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk