Allows an object managed by a pw::SharedPtr to safely generate additional pw::SharedPtr or pw::WeakPtr instances to itself.
Inheriting from EnableSharedFromThis<T> provides shared_from_this() and weak_from_this(), mirroring std::enable_shared_from_this.
EnableSharedFromThis<T> base must be public and unambiguous. With a private, protected, or duplicate base, weak_from_this() remains empty and shared_from_this() asserts.weak_this_ is only initialized by Allocator::MakeShared / SharedPtr::Create and by SharedPtr(UniquePtr&). It is not initialized for SharedPtr<T[]> or internally constructed SharedPtrs (e.g. async2::Task, multibuf).shared_from_this() asserts if called from the object's constructor or destructor.kSkipsDestroy capability (such as BumpAllocator), the object's destructor never executes, meaning weak_this_ never releases its weak reference and the control block is never deallocated.| T | The derived class type (CRTP pattern). |
Public Member Functions | |
| SharedPtr< T > | shared_from_this () |
| SharedPtr< const T > | shared_from_this () const |
| WeakPtr< T > | weak_from_this () noexcept |
| WeakPtr< const T > | weak_from_this () const noexcept |
Protected Member Functions | |
| constexpr | EnableSharedFromThis (const EnableSharedFromThis &) noexcept |
| constexpr | EnableSharedFromThis (EnableSharedFromThis &&) noexcept |
| constexpr EnableSharedFromThis & | operator= (const EnableSharedFromThis &) noexcept |
| constexpr EnableSharedFromThis & | operator= (EnableSharedFromThis &&) noexcept |
Friends | |
| template<typename , typename > | |
| struct | allocator::internal::HasInitializeWeakThis |
| template<typename U > | |
| void | allocator::internal::EnableWeakThis (allocator::internal::ControlBlock *, U *) |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |