// (C) Porkolab 2003 // // A.5.10. // // Array deleting adapter class for auto_ptr // #include <memory> #include <iostream> #include <vector> template <typename T> class ArrDelAdapter { public: ArrDelAdapter(T *p) : p_(p) { } ~ArrDelAdapter() { delete [] p_; } // operators like ->, *, etc... private: T* p_; }; struct X { X() { std::cout << "X()" << std::endl; } ~X() { std::cout << "~X()" << std::endl; } }; int main() { std::auto_ptr< ArrDelAdapter<X> > pp(new ArrDelAdapter<X>(new X[10])); return 0; }