Boost logo

Boost :

From: Ulrich Eckhardt (doomster_at_[hidden])
Date: 2006-03-29 03:15:31


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk