File indexing completed on 2025-12-16 09:53:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef BOOST_INTERPROCESS_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
0015 #define BOOST_INTERPROCESS_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
0016
0017 #ifndef BOOST_CONFIG_HPP
0018 # include <boost/config.hpp>
0019 #endif
0020 #
0021 #if defined(BOOST_HAS_PRAGMA_ONCE)
0022 # pragma once
0023 #endif
0024
0025 #include <boost/interprocess/detail/config_begin.hpp>
0026 #include <boost/interprocess/detail/workaround.hpp>
0027
0028 #include <boost/assert.hpp>
0029 #include <boost/interprocess/smart_ptr/weak_ptr.hpp>
0030 #include <boost/interprocess/smart_ptr/shared_ptr.hpp>
0031
0032
0033
0034
0035 namespace boost{
0036 namespace interprocess{
0037
0038
0039
0040
0041
0042 template<class T, class A, class D>
0043 class enable_shared_from_this
0044 {
0045 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0046 protected:
0047 enable_shared_from_this()
0048 {}
0049
0050 enable_shared_from_this(enable_shared_from_this const &)
0051 {}
0052
0053 enable_shared_from_this & operator=(enable_shared_from_this const &)
0054 { return *this; }
0055
0056 ~enable_shared_from_this()
0057 {}
0058 #endif
0059
0060 public:
0061 shared_ptr<T, A, D> shared_from_this()
0062 {
0063 shared_ptr<T, A, D> p(_internal_weak_this);
0064 BOOST_ASSERT(ipcdetail::to_raw_pointer(p.get()) == this);
0065 return p;
0066 }
0067
0068 shared_ptr<T const, A, D> shared_from_this() const
0069 {
0070 shared_ptr<T const, A, D> p(_internal_weak_this);
0071 BOOST_ASSERT(ipcdetail::to_raw_pointer(p.get()) == this);
0072 return p;
0073 }
0074
0075 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0076 typedef T element_type;
0077 mutable weak_ptr<element_type, A, D> _internal_weak_this;
0078 #endif
0079 };
0080
0081 }
0082 }
0083
0084 #include <boost/interprocess/detail/config_end.hpp>
0085
0086 #endif
0087