Given the semantics of std::auto_ptr, though, you could probably declare local auto_ptrs in the function, check for errors at the end of the function, and if there are no errors, pass ownership of the objects to permanent storage, something like this:
MyObject *ob1, *ob2, *obn;bool MyLoadFunc(){std::auto_ptr<MyObject> ptr1, ptr2, ptr3;if (!(ptr1 = new MyObject()))return false;if (!(ptr2 = new MyObject()))return false;if (!(ptrn = new MyObject()))return false;ob1 = ptr1.release();ob2 = ptr2.release();obn = ptrn.release();return true;}
i.e. if everything loads successfully, we remove control from the auto_ptrs, and assign them to the global (or whatever) pointers, and then they don't delete the resources at the end of the scope.