[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Re: Constructor bombs for copy objects.

> I have forgotten the need for constructor bombs.  If I have a
> constructor that won't abort, do I need constructor bombs?  This might
> be very common because we have such shallow inheritance trees.


A constructor bomb is needed IFF a BLAST that occurs in the constructor
>or anything it calls< isn't caught until it reaches a SHIELD outside the

The problem is that the storage returned by operator new (or the equivalent)
is held only by the "this" pointer (or other things in the constructor's
scope) until the constructor has successfully returned and the caller can
squirrel the pointer away.  Constructor bombs:
 - Take over the normal call to the memory allocator,
 - Arm themselves when they receive the memory from (operator) new, and:
   - disarm themselves quietly if the constructor returns normally, or
   - free the storage as the exception passes up out of the constructor.