scope(exit) foo(); // Call foo at the end of the scope scope(success) foo(); //Call foo if all goes well scope(failure) foo(); //Call foo if the wings fall off the plane.