The emi(basic guarantee) dictates that functions that fail to complete their
assigned tasks must return all allocated resources, usually memory, before
terminating. Since practically all functions and operators may throw
exceptions and since a function may repeatedly allocate resources the
blueprint of a function allocating resources shown below defines a try block
to catch all exceptions that might be thrown. The catch handler's task is to
return all allocated resources and then rethrow the exception.
        verb(
    void allocator(X **xDest, Y **yDest)
    {
        X *xp = 0;              // non-throwing preamble
        Y *yp = 0;

        try                     // this part might throw
        {
            xp = new X[nX];     // alternatively: allocate one object
            yp = new Y[nY];
        }
        catch(...)
        {
            delete xp;
            throw;
        }

        delete[] *xDest;        // non-throwing postamble
        *xDest = xp;
        delete[] *yDest;
        *yDest = yp;
    }
        )
    In the pre-try code the pointers to receive the addresses returned by the
operator tt(new) calls are initialized to 0. Since the catch handler must be
able to return allocated memory they must be available outside of the tt(try)
block. If the allocation succeeds the memory pointed to by the destination
pointers is returned and then the pointers are given new values.

    Allocation and or initialization might fail. If allocation fails tt(new)
throws a hi(bad_alloc)tt(std::bad_alloc) exception and the catch handler
simply deletes 0-pointers which is OK.

    If allocation succeeds but the construction of (some) of the objects fails
by throwing an exception then the following is
    hi(new: and exceptions)hi(exception: and new) em(guaranteed) to happen:
    itemization(
    it() The destructors of all successfully allocated objects are called;
    it() The dynamically allocated memory to contain the objects is returned
    )

    Consequently, there is no memory leak when tt(new) fails. Inside the above
tt(try) block tt(new X) may fail: this does not affect the 0-pointers
and so the catch handler merely deletes 0 pointers. When tt(new Y) fails
tt(xp) points to allocated memory and so it must be returned. This happens
inside the catch handler. The final pointer (here: tt(yp)) will only be
unequal zero when tt(new Y) properly completes, so there's no need for the
catch handler to return the memory pointed at by tt(yp).
