Originally posted by darwen
What are you trying to do here ?

The purpose of auto_ptr is to delete memory which you have newed e.g.
I'm declaring an auto_ptr< ifstream> variable in the header file of a class. At some point a new fstream is assigned to it. The purpose is to make sure the fstream gets destructed for sure. I've read in Effective C++ that the use of auto_ptr's is a way to ensure that. If I for example assign a new ifstream to this auto_ptr variable the old ifstream will get automatically deleted. To me it seams like a fool-proof way to avoid leaks?