Boost logo

Boost :

From: Andy Glew (glew_at_[hidden])
Date: 1999-07-23 14:46:41


>In general, I dislike intrusive templates. The auto_ptr, scoped_ptr, and shared_ptr
>templates make no special requirements on their type argument, which is, IMHO, an
>essential part of their general usefulness.
>
>Nonetheless, live_ptr looks useful, so I'd like to see if it can be done with minimal
>intrusion. I don't consider requiring derivation from live_ptee to be minimal.

Agreed: I dislike intrusive templates. I dislike derivation.

In other times, places, and languages my approach has been to wrapperize deallocation
of *all* objects: i.e. whenever deallocating the object at address A of size S, I check
a central registry looking for any addresses in that range. Typically a hashtable, if I don't
have to worry about internal pointers; a slower tree structure if I can't make that assumption.

This makes all deallocations a little bit slower, but if the hashtable is efficiently implemented
it's not too bad, particularly if special provision is made to quickly handle deallocation of
stack objects.

Unfortunately, I do not see a portable way to do this in C++. You can provide your own
destructors and memory managers, but I do not see a way to intercept all destructor or
deallocator calls portably.

I dislike the intrusiveness enough that I would suggest hacking the deallocation interception
for some important systems - VC++ and G++ - but I don't see a portable way to do this.


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