Question regarding ptr_containers
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? 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? I'm not arguing is hould be one way or the other ;) I just want to know the current behaviour. Thanks, /Z
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
participants (2)
-
Edwin Savarimuthu
-
Thorsten Ottosen