Boost logo

Boost Users :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2006-10-12 12:50:54


Edwin Savarimuthu wrote:
> Hi all,
> Excuse me if this is asked before. I have a question regarding pointer
> containers. I have an object A which comes from a third party and
> *unfortunately* it can throw an exception from the destructor. How
> ptr_container deals with this situation?

It assumes that the destructor does not throw.

> Let's say I have pointer container going out of scope and when it is
> trying to delete one of the contained pointer the object's destructor
> threw an exception. Does the container catch it, ignore it and proceeds
> with other delete-s? Or is it a requirement for the stored object that
> it shouldn't throw an exception from the destructor?

It would simply propagate the exception to the caller of the destructor,
leaving the rest of the objects non-destructed.

So, yes, it is a requirement that destructors don't throw. Like always.

You can change the CloneAllocator to one with a try-catch around the
call to delete.

-Thorsten


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net