fixing stuff
[dyninst.git] / dynutil / h / dyn_detail / boost / enable_shared_from_this.hpp
1 #ifndef DYN_DETAIL_BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
2 #define DYN_DETAIL_BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
3
4 //
5 //  enable_shared_from_this.hpp
6 //
7 //  Copyright (c) 2002 Peter Dimov
8 //
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
12 //
13 //  http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html
14 //
15
16 #include <dyn_detail/boost/weak_ptr.hpp>
17 #include <dyn_detail/boost/shared_ptr.hpp>
18 #include <dyn_detail/boost/assert.hpp>
19 #include <dyn_detail/boost/config.hpp>
20
21 namespace dyn_detail
22 {
23   
24 namespace boost
25 {
26
27 template<class T> class enable_shared_from_this
28 {
29 protected:
30
31     enable_shared_from_this()
32     {
33     }
34
35     enable_shared_from_this(enable_shared_from_this const &)
36     {
37     }
38
39     enable_shared_from_this & operator=(enable_shared_from_this const &)
40     {
41         return *this;
42     }
43
44     ~enable_shared_from_this()
45     {
46     }
47
48 public:
49
50     shared_ptr<T> shared_from_this()
51     {
52         shared_ptr<T> p(_internal_weak_this);
53         DYN_DETAIL_BOOST_ASSERT(p.get() == this);
54         return p;
55     }
56
57     shared_ptr<T const> shared_from_this() const
58     {
59         shared_ptr<T const> p(_internal_weak_this);
60         DYN_DETAIL_BOOST_ASSERT(p.get() == this);
61         return p;
62     }
63
64     typedef T _internal_element_type; // for bcc 5.5.1
65     mutable weak_ptr<_internal_element_type> _internal_weak_this;
66 };
67
68 } // namespace boost
69 } // namespace dyn_detail
70
71 #endif  // #ifndef DYN_DETAIL_BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED