Home
Base module

IntrusivePtr

Intrusive smart pointer for RefCounted objects.

IntrusivePtr

#include <icy/memory.h>
template<typename T>
class IntrusivePtr

Defined in src/base/include/icy/memory.h:90

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

List of all members

NameKindOwner
IntrusivePtrfunctionDeclared here
IntrusivePtrfunctionDeclared here
IntrusivePtrfunctionDeclared here
IntrusivePtrfunctionDeclared here
IntrusivePtrfunctionDeclared here
IntrusivePtrfunctionDeclared here
IntrusivePtrfunctionDeclared here
~IntrusivePtrfunctionDeclared here
operator=functionDeclared here
operator=functionDeclared here
operator=functionDeclared here
operator=functionDeclared here
resetfunctionDeclared here
resetfunctionDeclared here
getfunctionDeclared here
operator*functionDeclared here
operator->functionDeclared here
operator boolfunctionDeclared here
swapfunctionDeclared here
detachfunctionDeclared here
operator==functionDeclared here
operator!=functionDeclared here
operator==functionDeclared here
operator!=functionDeclared here
operator<functionDeclared here
_ptrvariableDeclared here

Public Methods

ReturnNameDescription
IntrusivePtr inline noexcept
IntrusivePtr inline noexcept
IntrusivePtr inline explicit noexcept
IntrusivePtr inline noexcept
IntrusivePtr inline noexcept
IntrusivePtr inline noexcept
IntrusivePtr inline noexcept
voidreset inline noexceptReleases ownership of the current pointer, decrementing its refcount. The pointer is set to null.
voidreset inline noexceptReleases the current pointer and takes ownership of p, incrementing its refcount.
T *get const inline noexceptReturns the raw pointer without transferring ownership.
T &operator* const inline noexceptDereferences the managed pointer.
T *operator-> const inline noexceptMember access on the managed pointer.
operator bool const inline explicit noexceptReturns true if the pointer is non-null.
voidswap inline noexceptSwaps the managed pointer with another IntrusivePtr.
voiddetach inline noexceptRelease ownership without decrementing refcount. Used internally for move construction across types.
booloperator== const inline noexcept
booloperator!= const inline noexcept
booloperator== const inline noexcept
booloperator!= const inline noexcept
booloperator< const inline noexcept

IntrusivePtr

inline noexcept

inline IntrusivePtr() noexcept

Defined in src/base/include/icy/memory.h:93


IntrusivePtr

inline noexcept

inline IntrusivePtr(std::nullptr_t) noexcept

Defined in src/base/include/icy/memory.h:94


IntrusivePtr

inline explicit noexcept

inline explicit IntrusivePtr(T * p) noexcept

Defined in src/base/include/icy/memory.h:96


IntrusivePtr

inline noexcept

inline IntrusivePtr(const IntrusivePtr & r) noexcept

Defined in src/base/include/icy/memory.h:101


IntrusivePtr

inline noexcept

template<typename U> inline IntrusivePtr(const IntrusivePtr< U > & r) noexcept

Defined in src/base/include/icy/memory.h:107


IntrusivePtr

inline noexcept

inline IntrusivePtr(IntrusivePtr && r) noexcept

Defined in src/base/include/icy/memory.h:112


IntrusivePtr

inline noexcept

template<typename U> inline IntrusivePtr(IntrusivePtr< U > && r) noexcept

Defined in src/base/include/icy/memory.h:118


reset

inline noexcept

inline void reset() noexcept

Defined in src/base/include/icy/memory.h:155

Releases ownership of the current pointer, decrementing its refcount. The pointer is set to null.


reset

inline noexcept

inline void reset(T * p) noexcept

Defined in src/base/include/icy/memory.h:162

Releases the current pointer and takes ownership of p, incrementing its refcount.

Parameters

  • p New raw pointer to manage (may be nullptr).

get

const inline noexcept

inline T * get() const noexcept

Defined in src/base/include/icy/memory.h:169

Returns the raw pointer without transferring ownership.

Returns

Raw pointer to the managed object, or nullptr.


operator*

const inline noexcept

inline T & operator*() const noexcept

Defined in src/base/include/icy/memory.h:173

Dereferences the managed pointer.

Returns

Reference to the managed object.


operator->

const inline noexcept

inline T * operator->() const noexcept

Defined in src/base/include/icy/memory.h:177

Member access on the managed pointer.

Returns

Raw pointer to the managed object.


operator bool

const inline explicit noexcept

inline explicit operator bool() const noexcept

Defined in src/base/include/icy/memory.h:180

Returns true if the pointer is non-null.


swap

inline noexcept

inline void swap(IntrusivePtr & r) noexcept

Defined in src/base/include/icy/memory.h:184

Swaps the managed pointer with another IntrusivePtr.

Parameters


detach

inline noexcept

inline void detach() noexcept

Defined in src/base/include/icy/memory.h:188

Release ownership without decrementing refcount. Used internally for move construction across types.


operator==

const inline noexcept

inline bool operator==(const IntrusivePtr & r) const noexcept

Defined in src/base/include/icy/memory.h:190


operator!=

const inline noexcept

inline bool operator!=(const IntrusivePtr & r) const noexcept

Defined in src/base/include/icy/memory.h:191


operator==

const inline noexcept

inline bool operator==(std::nullptr_t) const noexcept

Defined in src/base/include/icy/memory.h:192


operator!=

const inline noexcept

inline bool operator!=(std::nullptr_t) const noexcept

Defined in src/base/include/icy/memory.h:193


operator<

const inline noexcept

inline bool operator<(const IntrusivePtr & r) const noexcept

Defined in src/base/include/icy/memory.h:194

Private Attributes

ReturnNameDescription
T *_ptr

_ptr

T * _ptr

Defined in src/base/include/icy/memory.h:197