| 1 | // Copyright Frank Mori Hess 2009.
|
|---|
| 2 |
|
|---|
| 3 | // Distributed under the Boost Software License, Version
|
|---|
| 4 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|---|
| 5 | // http://www.boost.org/LICENSE_1_0.txt)
|
|---|
| 6 |
|
|---|
| 7 | #ifndef BOOST_SHARED_FROM_THIS
|
|---|
| 8 | #define BOOST_SHARED_FROM_THIS
|
|---|
| 9 |
|
|---|
| 10 | #include <boost/enable_shared_from_this.hpp>
|
|---|
| 11 | #include <boost/shared_ptr.hpp>
|
|---|
| 12 |
|
|---|
| 13 | namespace boost
|
|---|
| 14 | {
|
|---|
| 15 | template<typename T>
|
|---|
| 16 | shared_ptr<T> shared_from_this(T *p);
|
|---|
| 17 |
|
|---|
| 18 | class enable_shared_from_this_base: private enable_shared_from_this<enable_shared_from_this_base>
|
|---|
| 19 | {
|
|---|
| 20 | template<typename T> friend
|
|---|
| 21 | boost::shared_ptr<T> shared_from_this(T *p);
|
|---|
| 22 | template<typename T> friend
|
|---|
| 23 | class boost::shared_ptr;
|
|---|
| 24 | friend class enable_shared_from_this<enable_shared_from_this_base>;
|
|---|
| 25 | };
|
|---|
| 26 |
|
|---|
| 27 | template<typename T>
|
|---|
| 28 | shared_ptr<T> shared_from_this(T *p)
|
|---|
| 29 | {
|
|---|
| 30 | return shared_ptr<T>(p->shared_from_this(), p);
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | #endif // BOOST_SHARED_FROM_THIS
|
|---|