1 #ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
2 #define BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
5 // enable_shared_from_this.hpp
7 // Copyright (c) 2002 Peter Dimov
9 // Permission to copy, use, modify, sell and distribute this software
10 // is granted provided this copyright notice appears in all copies.
11 // This software is provided "as is" without express or implied
12 // warranty, and with no claim as to its suitability for any purpose.
14 // http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html
17 #include <boost/weak_ptr.hpp>
18 #include <boost/shared_ptr.hpp>
19 #include <boost/assert.hpp>
20 #include <boost/config.hpp>
25 template<class T> class enable_shared_from_this
29 enable_shared_from_this()
33 enable_shared_from_this(enable_shared_from_this const &)
37 enable_shared_from_this & operator=(enable_shared_from_this const &)
42 ~enable_shared_from_this()
48 shared_ptr<T> shared_from_this()
50 shared_ptr<T> p(_internal_weak_this);
51 BOOST_ASSERT(p.get() == this);
55 shared_ptr<T const> shared_from_this() const
57 shared_ptr<T const> p(_internal_weak_this);
58 BOOST_ASSERT(p.get() == this);
62 typedef T _internal_element_type; // for bcc 5.5.1
63 weak_ptr<_internal_element_type> _internal_weak_this;
68 #endif // #ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED