• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef BOOST_SMART_PTR_ENABLE_SHARED_FROM_HPP_INCLUDED
2 #define BOOST_SMART_PTR_ENABLE_SHARED_FROM_HPP_INCLUDED
3 
4 //  enable_shared_from.hpp
5 //
6 //  Copyright 2019, 2020 Peter Dimov
7 //
8 //  Distributed under the Boost Software License, Version 1.0.
9 //  See accompanying file LICENSE_1_0.txt or copy at
10 //  http://www.boost.org/LICENSE_1_0.txt
11 //
12 //  See http://www.boost.org/libs/smart_ptr/ for documentation.
13 
14 #include <boost/smart_ptr/enable_shared_from_this.hpp>
15 #include <boost/smart_ptr/detail/sp_noexcept.hpp>
16 
17 namespace boost
18 {
19 
20 class enable_shared_from: public enable_shared_from_this<enable_shared_from>
21 {
22 private:
23 
24     using enable_shared_from_this<enable_shared_from>::shared_from_this;
25     using enable_shared_from_this<enable_shared_from>::weak_from_this;
26 };
27 
28 
shared_from(T * p)29 template<class T> shared_ptr<T> shared_from( T * p )
30 {
31     return shared_ptr<T>( p->enable_shared_from_this<enable_shared_from>::shared_from_this(), p );
32 }
33 
weak_from(T * p)34 template<class T> weak_ptr<T> weak_from( T * p ) BOOST_SP_NOEXCEPT
35 {
36     return weak_ptr<T>( p->enable_shared_from_this<enable_shared_from>::weak_from_this(), p );
37 }
38 
39 } // namespace boost
40 
41 #endif  // #ifndef BOOST_SMART_PTR_ENABLE_SHARED_FROM_HPP_INCLUDED
42