From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-12-01 06:57:17
Sohail Somani wrote:
> Please see the following email about additional template parameters for
> scoped_ptr. The quick hack I wrote for it is below (I've used this in
> previous project as well). I think it would be very useful to many users
> and wouldn't change any source using scoped_ptr.
This question makes me feel nostalgic. My first request on this list looked very
similar (I needed to Release() COM objects). I just dug up the reply and it
seems there used to be this kind of parametrized deletion for shared_ptr.
I learned a lot about C++ design since then (not at least because of lurking in
this unique and elite forum ;-) ) and I'd propose a different interface for that
Actually, I don't think that parametrized deletion belongs into the interface of
a smart pointer. It's up to other components to have proper deletion semantics.
Still, there sure are cases (dealing with third-party or plain C components)
where it is a practical thing to have. So I'd probably ask for a freestanding
function that is called without qualification to do the deletion (just using
delete by default), so it can be overloaded and found via ADL and we don't need
to change and mess up the interface of the smart pointer.
BTW. I just noticed there is some "get_deleter logic" (marked as experimental in
a comment) based on RTTI in 'shared_ptr.hpp'. What's that all about? Heap
selection when using shared libraries?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk