-
Re: Use of auto_ptr
Of course you can use an auto_ptr pretty much anywhere you can use a normal pointer (with careful use of release() etc.), it's just that there are better alternatives in most cases. If you don't use any smart pointers other than auto_ptr and shared_ptr, then you might be inclined to use auto_ptr in a lot more circumstances than if you have a suite of smart pointers to choose from.
For example, if you want deep copy semantics, use a cloning pointer, if you need shared sematics, use shared_ptr, if you don't want copyability, use scoped_ptr. That leaves auto_ptr with ownership passing as its main speciality (e.g. as function parameters and returns), on which a lot of design time was spent to make sure it works (which it doesn't perfectly). However, it's likely to lose that role to move_ptr in the future, when move semantics are added to C++. That will leave it as the default scoped pointer for those not using boost or their own smart pointers, but without many other uses.
-
Re: Use of auto_ptr
Check out the following link on smart pointers:
http://axter.com/smartptr
The above link include a smart pointer that can be used in a vector, and additional information on different types of smart pointers.