nuclear@0: nuclear@0: #ifndef __AI_BOOST_SCOPED_PTR_INCLUDED nuclear@0: #define __AI_BOOST_SCOPED_PTR_INCLUDED nuclear@0: nuclear@0: #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED nuclear@0: nuclear@0: namespace boost { nuclear@0: nuclear@0: // small replacement for boost::scoped_ptr nuclear@0: template nuclear@0: class scoped_ptr nuclear@0: { nuclear@0: public: nuclear@0: nuclear@0: // provide a default construtctor nuclear@0: scoped_ptr() nuclear@0: : ptr(0) nuclear@0: { nuclear@0: } nuclear@0: nuclear@0: // construction from an existing heap object of type T nuclear@0: scoped_ptr(T* _ptr) nuclear@0: : ptr(_ptr) nuclear@0: { nuclear@0: } nuclear@0: nuclear@0: // automatic destruction of the wrapped object at the nuclear@0: // end of our lifetime nuclear@0: ~scoped_ptr() nuclear@0: { nuclear@0: delete ptr; nuclear@0: } nuclear@0: nuclear@0: inline T* get() const nuclear@0: { nuclear@0: return ptr; nuclear@0: } nuclear@0: nuclear@0: inline operator T*() nuclear@0: { nuclear@0: return ptr; nuclear@0: } nuclear@0: nuclear@0: inline T* operator-> () nuclear@0: { nuclear@0: return ptr; nuclear@0: } nuclear@0: nuclear@0: inline void reset (T* t = 0) nuclear@0: { nuclear@0: delete ptr; nuclear@0: ptr = t; nuclear@0: } nuclear@0: nuclear@0: void swap(scoped_ptr & b) nuclear@0: { nuclear@0: std::swap(ptr, b.ptr); nuclear@0: } nuclear@0: nuclear@0: private: nuclear@0: nuclear@0: // encapsulated object pointer nuclear@0: T* ptr; nuclear@0: nuclear@0: }; nuclear@0: nuclear@0: template nuclear@0: inline void swap(scoped_ptr & a, scoped_ptr & b) nuclear@0: { nuclear@0: a.swap(b); nuclear@0: } nuclear@0: nuclear@0: } // end of namespace boost nuclear@0: nuclear@0: #else nuclear@0: # error "scoped_ptr.h was already included" nuclear@0: #endif nuclear@0: #endif // __AI_BOOST_SCOPED_PTR_INCLUDED nuclear@0: