Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/boost/enable_shared_from_this.hpp @ 16

Last change on this file since 16 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.4 KB
Line 
1#ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
2#define 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 <boost/weak_ptr.hpp>
17#include <boost/shared_ptr.hpp>
18#include <boost/assert.hpp>
19#include <boost/config.hpp>
20
21namespace boost
22{
23
24template<class T> class enable_shared_from_this
25{
26protected:
27
28    enable_shared_from_this()
29    {
30    }
31
32    enable_shared_from_this(enable_shared_from_this const &)
33    {
34    }
35
36    enable_shared_from_this & operator=(enable_shared_from_this const &)
37    {
38        return *this;
39    }
40
41    ~enable_shared_from_this()
42    {
43    }
44
45public:
46
47    shared_ptr<T> shared_from_this()
48    {
49        shared_ptr<T> p(_internal_weak_this);
50        BOOST_ASSERT(p.get() == this);
51        return p;
52    }
53
54    shared_ptr<T const> shared_from_this() const
55    {
56        shared_ptr<T const> p(_internal_weak_this);
57        BOOST_ASSERT(p.get() == this);
58        return p;
59    }
60
61    typedef T _internal_element_type; // for bcc 5.5.1
62    mutable weak_ptr<_internal_element_type> _internal_weak_this;
63};
64
65} // namespace boost
66
67#endif  // #ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.