Either use a boost auto pointer, or roll your own quickly:
template<typename T>class EasyAutoPtr { T* t; public: static EasyAutoPtr FromNewCreation(T* t_) {return EasyAutoPtr(t_, true);} explicit EasyAutoPtr(T* t_, bool take_reference=false):t(t_){if (!take_reference) t->AddRef();} T* StealReference() { T* tmp = t; t = 0; return tmp; } T* BorrowReference() {return t;} T* BorrowReference() const {return t;} T* DuplicateReference() {if (t) t->AddRef(); return t;} T* DuplicateReference() const {if (t) t->AddRef(); return t;} void swap(EasyAutoPtr<T>& other) {swap(t, other.t);} virtual ~EasyAutoPtr() {if(t)t->RemoveRef();} template<typename Other> EasyAutoPtr(Other const& o):t(o.DuplicateReference()) {} template<typename Other> EasyAutoPtr<T> const& operator=(Other const& o) { EasyAutoPtr<T> tmp = o; this->swap(tmp); return *this; } operator T*() { return BorrowReference(); } operator T const*() const { return BorrowReference(); }; T* operator->() { return BorrowReference(); } T const* operator->() const { return BorrowReference(); } T& operator*() { return BorrowReference(); } T const& operator*() const { return BorrowReference(); }};
(I would advise using a boost auto pointer -- I've written multiple auto pointer classes, and odds are the above one I whipped together has a bug!)