
I wonder if we boost has anything useful for implementing reference counting (or other gc) for objects? I know we have shared_ptr, but I was interested in objects rather than pointers.

On 3/27/06, Neal Becker <ndbecker2@gmail.com> wrote:
I wonder if we boost has anything useful for implementing reference counting (or other gc) for objects? I know we have shared_ptr, but I was interested in objects rather than pointers.
Isn't there an intrusive version of it that can be used for your purpose?

On 3/27/06, Neal Becker <ndbecker2@gmail.com> wrote:
I wonder if we boost has anything useful for implementing reference counting (or other gc) for objects? I know we have shared_ptr, but I was interested in objects rather than pointers.
How about boost::intrusive_ptr? http://boost.org/libs/smart_ptr/intrusive_ptr.html -- Caleb Epstein caleb dot epstein at gmail dot com

On Monday 27 March 2006 14:09, Neal Becker wrote:
I wonder if we boost has anything useful for implementing reference counting (or other gc) for objects? I know we have shared_ptr, but I was interested in objects rather than pointers.
I'm currently hacking on a shared array class template[1], and doing so I had the idea of providing a shared_resource template. Just like shared_ptr primarily combines a refcount with a pointer and in the second step with a custom deleter, I thought about combining the refcounter with an arbitrary resource. What I'm currently not sure about is how this resource could be accessed. For shared_ptr, the case is pretty clear, it just provides the typical operations that smart pointers provide (in order to mimic raw pointers' behaviour). For an arbitrary resource you might want different operations. For example, an array would want operator[], size and maybe a raw pointer access, a win32 HWND would only support a raw HWND conversion because the number of functions that would be required are otherwise unlimited. I think some kind of traits and the means to customise them would be called-for. Sounds reasonable? Uli [1] boost::shared_array doesn't cut it, it is barely different than a shared_ptr with a custom deleter, the only thing it does is prevent conversion to base-class or void pointers. Also, I want the size of the array.
participants (4)
-
Caleb Epstein
-
Neal Becker
-
Olaf van der Spek
-
Ulrich Eckhardt