Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-01-04 08:13:13


Pablo Aguilar wrote:
> Hi,
>
> I'm currently playing around with Apache's Xerces XML library, and
> found myself needing to ->release some pointers. shared_ptr + mem_fn
> works great:
> shared_ptr<DOMBuilder> db(
> impl->createBuilder()
> , mem_fn(&DOMBuilder::release)
> );
>
> But for the objects I'm using, I don't need a shared_ptr, but just a
> scoped_ptr. So I'm wondering about the rationale behind not giving
> scoped_ptr a custom deleter? Is it that shared_ptr's overhead is
> negligible (when not being shared I mean)?

No, it's that the overhead of a custom deleter (with state) is negligible in
shared_ptr's case, but significant in scoped_ptr's case. You'd typically
like to return this pointer from a factory function to avoid repeating the
deleter part everywhere, too. scoped_ptr can't be returned.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net