Clean allocation and construction of one object with the standard C++98/03
<p>In my code I need to allocate and construct an object dynamically and push the pointer to it into a vector. Is there a cleaner way to this than the code below without using all those ugly try-catch blocks? I cannot use non-standard libraries. There is no C++11. I only have the standard C++98/03. </p>

<pre><code>void insert() {
            //...do something...
            MyType* obj = 0;
            try {
                obj = alloc.allocate(1); // yes, even the allocation must be inside one try-catch in my case, since I need to undo something
                alloc.construct(obj, default_obj);
                try {
                    v.push_back(obj);
                } catch (...) {
                    alloc.destroy(obj);
                    throw;
                }
            } catch (...) {
                //..undo something..
                if (obj)
                    alloc.deallocate(obj, 1);
                throw;
            }
}
</code></pre>

<p>EDIT:
alloc is an allocator passed as argument somewhere to avoid raw new/delete. v is a vector.</p>
