Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-12-11 12:48:36


>From: "Alan Bellingham" <alan_at_[hidden]>

> Terje Slettebø <tslettebo_at_[hidden]>:
>
> >>>in this thread, void * is type erasure. More or less the only safe
thing you
> >>>can do with it, is to delete it. You can also cast it back to its
original
>
> [snip David Abrahams demurral]
>
> >Of course, it depends on whether the type supports polymorphic deletion,
and
> >whether or not it's an array (so you would need delete[]), but are there
> >other issues besides this? I assumed that if types were used in this way,
> >then at least the above was known.
>
> Well, in addition, you've forgotten that because void* has no type
> associated with it, any real object behind the pointer will not have its
> dtor called. Not good news, usually.

Right. I came to think of that after I sent it. So not even calling delete
on it is safe.

Regards,

Terje


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