IntrusivePtr
IntrusivePtr
#include <icy/memory.h>Intrusive smart pointer for RefCounted objects.
Like std::shared_ptr but with zero allocation overhead:
No separate control block (refcount is embedded in the object)
Non-atomic refcount (safe for single-threaded libuv loops)
Same API as shared_ptr for easy migration
Public Methods
| Return | Name | Description |
|---|---|---|
IntrusivePtr inline | ||
IntrusivePtr inline | ||
IntrusivePtr inline explicit | ||
IntrusivePtr inline | ||
IntrusivePtr inline | ||
IntrusivePtr inline | ||
IntrusivePtr inline | ||
void | reset inline | Releases ownership of the current pointer, decrementing its refcount. The pointer is set to null. |
void | reset inline | Releases the current pointer and takes ownership of p, incrementing its refcount. |
T * | get const inline | Returns the raw pointer without transferring ownership. |
T & | operator* const inline | Dereferences the managed pointer. |
T * | operator-> const inline | Member access on the managed pointer. |
operator bool const inline explicit | Returns true if the pointer is non-null. | |
void | swap inline | Swaps the managed pointer with another IntrusivePtr. |
void | detach inline | Release ownership without decrementing refcount. Used internally for move construction across types. |
bool | operator== const inline | |
bool | operator!= const inline | |
bool | operator== const inline | |
bool | operator!= const inline | |
bool | operator< const inline |
IntrusivePtr
inline
inline IntrusivePtr() noexceptIntrusivePtr
inline
inline IntrusivePtr(std::nullptr_t) noexceptIntrusivePtr
inline explicit
inline explicit IntrusivePtr(T * p) noexceptIntrusivePtr
inline
inline IntrusivePtr(const IntrusivePtr & r) noexceptIntrusivePtr
inline
template<typename U> inline IntrusivePtr(const IntrusivePtr< U > & r) noexceptIntrusivePtr
inline
inline IntrusivePtr(IntrusivePtr && r) noexceptIntrusivePtr
inline
template<typename U> inline IntrusivePtr(IntrusivePtr< U > && r) noexceptreset
inline
inline void reset() noexceptReleases ownership of the current pointer, decrementing its refcount. The pointer is set to null.
reset
inline
inline void reset(T * p) noexceptReleases the current pointer and takes ownership of p, incrementing its refcount.
Parameters
pNew raw pointer to manage (may be nullptr).
get
const inline
inline T * get() const noexceptReturns the raw pointer without transferring ownership.
Returns
Raw pointer to the managed object, or nullptr.
operator*
const inline
inline T & operator*() const noexceptDereferences the managed pointer.
Returns
Reference to the managed object.
operator->
const inline
inline T * operator->() const noexceptMember access on the managed pointer.
Returns
Raw pointer to the managed object.
operator bool
const inline explicit
inline explicit operator bool() const noexceptReturns true if the pointer is non-null.
swap
inline
inline void swap(IntrusivePtr & r) noexceptSwaps the managed pointer with another IntrusivePtr.
Parameters
rThe other IntrusivePtr to swap with.
detach
inline
inline void detach() noexceptRelease ownership without decrementing refcount. Used internally for move construction across types.
operator==
const inline
inline bool operator==(const IntrusivePtr & r) const noexceptoperator!=
const inline
inline bool operator!=(const IntrusivePtr & r) const noexceptoperator==
const inline
inline bool operator==(std::nullptr_t) const noexceptoperator!=
const inline
inline bool operator!=(std::nullptr_t) const noexceptoperator<
const inline
inline bool operator<(const IntrusivePtr & r) const noexceptPrivate Attributes
| Return | Name | Description |
|---|---|---|
T * | _ptr |
_ptr
T * _ptr