Template Class IntrusivePtrEnabled¶
Defined in File intrusive_ptr.hpp
Class Documentation¶
-
template<typename
T, typenameDeleter, typenameReferenceTracker>
classwrench::IntrusivePtrEnabled¶ Provides reference tracking and deleting functionality which can be inherited to enable IntrusivePtr functionality.
- Template Parameters
T: The type of the pointer.Deleter: The type of the deleter for the object.ReferenceTracker: The type of the refrence tracker.
Public Types
-
using
IntrusivePointer= IntrusivePtr<Enabled>¶ Defines the type of the intrusive pointer.
-
using
RefTracker= ReferenceTracker¶ Defines the type of the reference tracker.
Public Functions
-
IntrusivePtrEnabled() = default¶ Constructor, which initializes the count and checks that the reference tracker implements the RefTracker interface.
-
IntrusivePtrEnabled(IntrusivePtrEnabled &&other) noexcept = default¶ Here we enable move semantics as a performance optimization, which results in less atomics than just copying.
- Parameters
other: The other type to move.
-
auto operator= (IntrusivePtrEnabled &&other) noexcept -> IntrusivePtrEnabled &=default Here we enable move semantics as a performance optimization. It would be quite fine to just copy the intrusive pointer and then deleted the old one. However, in a multi-threaded context, this will result in two atomic operations, when we can just move the reference tracker and have none.
- Parameters
other: The other type to move.
-
IntrusivePtrEnabled(const IntrusivePtrEnabled&) = delete¶ Copy constructor deleted.
-
auto
operator=(const IntrusivePtrEnabled&) = delete¶ Copy assignment operator deleted.
-
auto release_reference () noexcept -> void Releases the reference to the pointed to object, deleting the object if the reference count gets to zero.
-
void
add_reference() noexcept¶ Adds a reference to the tracked reference count.
Protected Functions
-
auto reference_from_this () noexcept -> IntrusivePointer Creates a new intrusive pointer from the pointed to object, incrementing the reference count.
Implementation for creating a reference from an intrusive pointer enbled type.
- Template Parameters
T: The to create an intrusive pointer for.Deleter: The deleter for the object.Tracker: The type of the reference tracker.