Boost logo

Boost Users :

Subject: Re: [Boost-users] [Smart Pointer] Reference counting when you don't want to manage memory [Honeywell Internal]
From: Bruce Stephens (bruce.r.stephens_at_[hidden])
Date: 2014-08-26 15:50:03


On Tue, Aug 26, 2014 at 8:35 PM, Hickman, Steve (AdvTech)
<Steve.Hickman_at_[hidden]> wrote:
> Smart pointers (as in
> http://www.boost.org/doc/libs/1_56_0/libs/smart_ptr/smart_ptr.htm ) assume
> that the action you want to perform when the count goes to zero is to free
> the memory pointed to. That isn’t the only use for reference counting.
> Why doesn’t the Smart Pointer library decouple the reference counting from
> the action to be taken and provide a generic reference counting mechanism
> that will call an arbitrary function when the count goes to zero? The
> default can be “delete” to provide the expected memory management capability
> but it would provide a robust mechanism for those who need other
> capabilities.

You can pass in a deleter (it's an argument to the constructors, not
part of the type).
Doesn't that do what you want?


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