1 #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
2 #define BOOST_SCOPED_PTR_HPP_INCLUDED
4 // (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
5 // Copyright (c) 2001, 2002 Peter Dimov
7 // Permission to copy, use, modify, sell and distribute this software
8 // is granted provided this copyright notice appears in all copies.
9 // This software is provided "as is" without express or implied
10 // warranty, and with no claim as to its suitability for any purpose.
12 // See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation.
15 #include <boost/assert.hpp>
16 #include <boost/checked_delete.hpp>
21 // scoped_ptr mimics a built-in pointer except that it guarantees deletion
22 // of the object pointed to, either on destruction of the scoped_ptr or via
23 // an explicit reset(). scoped_ptr is a simple solution for simple needs;
24 // use shared_ptr or std::auto_ptr if your needs are more complex.
26 template<typename T> class scoped_ptr // noncopyable
32 scoped_ptr(scoped_ptr const &);
33 scoped_ptr & operator=(scoped_ptr const &);
37 typedef T element_type;
39 explicit scoped_ptr(T * p = 0): ptr(p) // never throws
43 ~scoped_ptr() // never throws
48 void reset(T * p = 0) // never throws
57 T & operator*() const // never throws
59 BOOST_ASSERT(ptr != 0);
63 T * operator->() const // never throws
65 BOOST_ASSERT(ptr != 0);
69 T * get() const // never throws
74 void swap(scoped_ptr & b) // never throws
82 template<typename T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) // never throws
89 #endif // #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED