Boost logo

Boost :

From: Bronek Kozicki (brok_at_[hidden])
Date: 2004-01-20 05:24:17

Jonathan Turkanis <technews_at_[hidden]> wrote:
> I'm sorry if you mentioned this possibility and I overlooked it. I

I did not mention this on boost (my fault); but you can find it in

> think the proper conclusion is the usual one: if you use a
> pointer-to-derived as a pointer-to-base, you can't expect correct
> deletion unless you have a virtual destructor. Do you disagree?

I would use different words, but basicaly this old truth is still valid.
*Under certain circumstances* one may use deleter to provide correct
deletion without polymorphism but still, from OOP point of view, there's
little point using inheritance without polymorhism. On the other hand,
C++ supports more programming paradigms than just OO, thus such deleter
support can be *sometimes* useful. BTW: shared_ptr has the very same
limitation, and AFAIK (limited) use of deleter to provide correct
deletion of non-polymorphic class is not really advertised in its

I can see one good use for deleter (providing correct deletion of
non-polymorphic class): when returning pointer to private class derived
from user supplied class, and user is allowed to supply non-polymorphic
class. Example is "universal factory", which simple implementation can
be found at:
(another, yet not quite finished, implementation of "universal factory"
is here: - anybody interested in seeing
something similar in boost ?)



Boost list run by bdawes at, gregod at, cpdaniel at, john at