This example was taken from Stroustup's book, third edition, Section 14.4.2 :
void f (Point p1, Point p2, auto_ptr<Circle> pc, Shape* pb)
{
auto_ptr<Shape> p (new Rectangle(p1 ,p2));
auto_ptr<Shape> pbox(pb);
p->rotate(45);
/ / ...
if (in_a_mess ) throw Mess();
/ / ...
}
"Here the Rectangle, the Shape pointed to by pb, and the Circle pointed to by pc are deleted whether or not an exception is thrown."