Add operator unspecified-bool-type to agi::scoped_ptr

Originally committed to SVN as r5844.
This commit is contained in:
Thomas Goyne 2011-11-12 01:23:09 +00:00
parent d4ee9da474
commit 0b742ef3c1

View file

@ -33,12 +33,15 @@ class scoped_ptr {
T* ptr;
scoped_ptr(scoped_ptr const&);
scoped_ptr& operator=(scoped_ptr const&);
typedef T *scoped_ptr<T>::*unspecified_bool_type;
public:
typedef T element_type;
T& operator*() const {return *ptr; }
T* operator->() const { return ptr; }
T* get() const { return ptr; }
operator unspecified_bool_type() const { return ptr ? &scoped_ptr<T>::ptr : 0; }
void reset(T *p = 0) {
delete ptr;