enable_shared_from.hpp 974 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef BOOST_SMART_PTR_ENABLE_SHARED_FROM_HPP_INCLUDED
  2. #define BOOST_SMART_PTR_ENABLE_SHARED_FROM_HPP_INCLUDED
  3. // enable_shared_from.hpp
  4. //
  5. // Copyright 2019 Peter Dimov
  6. //
  7. // Distributed under the Boost Software License, Version 1.0.
  8. // See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt
  10. //
  11. // See http://www.boost.org/libs/smart_ptr/ for documentation.
  12. #include <boost/smart_ptr/enable_shared_from_this.hpp>
  13. #include <boost/smart_ptr/detail/sp_noexcept.hpp>
  14. namespace boost
  15. {
  16. class enable_shared_from: public enable_shared_from_this<enable_shared_from>
  17. {
  18. };
  19. template<class T> shared_ptr<T> shared_from( T * p )
  20. {
  21. return shared_ptr<T>( p->enable_shared_from::shared_from_this(), p );
  22. }
  23. template<class T> weak_ptr<T> weak_from( T * p ) BOOST_SP_NOEXCEPT
  24. {
  25. return weak_ptr<T>( p->enable_shared_from::weak_from_this(), p );
  26. }
  27. } // namespace boost
  28. #endif // #ifndef BOOST_SMART_PTR_ENABLE_SHARED_FROM_HPP_INCLUDED