From: Murray Cumming (murrayc_at_[hidden])
Date: 2001-08-17 08:51:59
Peter Dimov wrote:
> From: "Murray Cumming" <murrayc_at_[hidden]>
> > Sorry, I read that as 'address of myalloc', instead of 'myalloc()'. This
> > might be enough, though it's less flexible. In particular, a custom
> > allocator would allow more use of a deallocator function that took args.
> 'bind' can help with this:
> shared_ptr<sybase_context> p(my_create_connection(constructor-args),
> bind(&my_destroy_connection, destroy-args));
Yes, that could help but that would all be less obvious than an
allocator. However, I'm not going to push the idea too hard because I
think that Peter Dimov's
shared_ptr<my_type> p(my_alloc(), &my_drop);
idea solves most of the problem. And, even though I have a general
dislike of function pointers and the assumptions that they make about
the functions that you'd want to use, I think that this might actually
be clearer for the majority of cases.
> > > It's not as elegant as a dedicated smart handle class, granted. If you
> > > decide to go that route you'll find that detail/shared_count.hpp does
> > > of the work for you. :-)
> > That's not very obvious to me.
> I don't have the time at the moment to write the documentation for
> shared_count (it looks like it deserves boost:: status) but I'd probably
> have to if my proposed changes to shared_ptr are accepted.
> For now, simply take a look at
> Most of it is boilerplate code that supports the shared_ptr specific
> interface. The real work is done by the shared_count member 'pn'. You can
> easily adapt shared_ptr into a sybase-specific smart handle.
> Of course I don't want to imply that your allocator idea is not worth
> Peter Dimov
> Multi Media Ltd.
> Info: http://www.boost.org Unsubscribe: <mailto:boost-unsubscribe_at_[hidden]>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
-- Murray Cumming www.murrayc.com murrayc_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk