WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
sleipnir::IntrusiveSharedPtr< T > Class Template Reference

A custom intrusive shared pointer implementation without thread synchronization overhead. More...

#include </home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/util/IntrusiveSharedPtr.hpp>

Public Member Functions

constexpr IntrusiveSharedPtr () noexcept=default
 Constructs an empty intrusive shared pointer.
 
constexpr IntrusiveSharedPtr (std::nullptr_t) noexcept
 Constructs an empty intrusive shared pointer.
 
constexpr IntrusiveSharedPtr (T *ptr) noexcept
 Constructs an intrusive shared pointer from the given pointer and takes ownership.
 
constexpr ~IntrusiveSharedPtr ()
 
constexpr IntrusiveSharedPtr (const IntrusiveSharedPtr< T > &rhs) noexcept
 Copy constructs from the given intrusive shared pointer.
 
constexpr IntrusiveSharedPtr< T > & operator= (const IntrusiveSharedPtr< T > &rhs) noexcept
 Makes a copy of the given intrusive shared pointer.
 
constexpr IntrusiveSharedPtr (IntrusiveSharedPtr< T > &&rhs) noexcept
 Move constructs from the given intrusive shared pointer.
 
constexpr IntrusiveSharedPtr< T > & operator= (IntrusiveSharedPtr< T > &&rhs) noexcept
 Move assigns from the given intrusive shared pointer.
 
constexpr T * Get () const noexcept
 Returns the internal pointer.
 
constexpr T & operator* () const noexcept
 Returns the object pointed to by the internal pointer.
 
constexpr T * operator-> () const noexcept
 Returns the internal pointer.
 
constexpr operator bool () const noexcept
 Returns true if the internal pointer isn't nullptr.
 

Friends

constexpr bool operator== (const IntrusiveSharedPtr< T > &lhs, const IntrusiveSharedPtr< T > &rhs) noexcept
 Returns true if the given intrusive shared pointers point to the same object.
 
constexpr bool operator!= (const IntrusiveSharedPtr< T > &lhs, const IntrusiveSharedPtr< T > &rhs) noexcept
 Returns true if the given intrusive shared pointers point to different objects.
 
constexpr bool operator== (const IntrusiveSharedPtr< T > &lhs, std::nullptr_t) noexcept
 Returns true if the left-hand intrusive shared pointer points to nullptr.
 
constexpr bool operator== (std::nullptr_t, const IntrusiveSharedPtr< T > &rhs) noexcept
 Returns true if the right-hand intrusive shared pointer points to nullptr.
 
constexpr bool operator!= (const IntrusiveSharedPtr< T > &lhs, std::nullptr_t) noexcept
 Returns true if the left-hand intrusive shared pointer doesn't point to nullptr.
 
constexpr bool operator!= (std::nullptr_t, const IntrusiveSharedPtr< T > &rhs) noexcept
 Returns true if the right-hand intrusive shared pointer doesn't point to nullptr.
 

Detailed Description

template<typename T>
class sleipnir::IntrusiveSharedPtr< T >

A custom intrusive shared pointer implementation without thread synchronization overhead.

Types used with this class should have three things:

  1. A zero-initialized public counter variable that serves as the shared pointer's reference count.
  2. A free function void IntrusiveSharedPtrIncRefCount(T*) that increments the reference count.
  3. A free function void IntrusiveSharedPtrDecRefCount(T*) that decrements the reference count and deallocates the pointed to object if the reference count reaches zero.
Template Parameters
TThe type of the object to be reference counted.

Constructor & Destructor Documentation

◆ IntrusiveSharedPtr() [1/5]

template<typename T >
sleipnir::IntrusiveSharedPtr< T >::IntrusiveSharedPtr ( )
constexprdefaultnoexcept

Constructs an empty intrusive shared pointer.

◆ IntrusiveSharedPtr() [2/5]

template<typename T >
sleipnir::IntrusiveSharedPtr< T >::IntrusiveSharedPtr ( std::nullptr_t )
inlineconstexprnoexcept

Constructs an empty intrusive shared pointer.

◆ IntrusiveSharedPtr() [3/5]

template<typename T >
sleipnir::IntrusiveSharedPtr< T >::IntrusiveSharedPtr ( T * ptr)
inlineexplicitconstexprnoexcept

Constructs an intrusive shared pointer from the given pointer and takes ownership.

◆ ~IntrusiveSharedPtr()

template<typename T >
sleipnir::IntrusiveSharedPtr< T >::~IntrusiveSharedPtr ( )
inlineconstexpr

◆ IntrusiveSharedPtr() [4/5]

template<typename T >
sleipnir::IntrusiveSharedPtr< T >::IntrusiveSharedPtr ( const IntrusiveSharedPtr< T > & rhs)
inlineconstexprnoexcept

Copy constructs from the given intrusive shared pointer.

◆ IntrusiveSharedPtr() [5/5]

template<typename T >
sleipnir::IntrusiveSharedPtr< T >::IntrusiveSharedPtr ( IntrusiveSharedPtr< T > && rhs)
inlineconstexprnoexcept

Move constructs from the given intrusive shared pointer.

Member Function Documentation

◆ Get()

template<typename T >
T * sleipnir::IntrusiveSharedPtr< T >::Get ( ) const
inlineconstexprnoexcept

Returns the internal pointer.

◆ operator bool()

template<typename T >
sleipnir::IntrusiveSharedPtr< T >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Returns true if the internal pointer isn't nullptr.

◆ operator*()

template<typename T >
T & sleipnir::IntrusiveSharedPtr< T >::operator* ( ) const
inlineconstexprnoexcept

Returns the object pointed to by the internal pointer.

◆ operator->()

template<typename T >
T * sleipnir::IntrusiveSharedPtr< T >::operator-> ( ) const
inlineconstexprnoexcept

Returns the internal pointer.

◆ operator=() [1/2]

template<typename T >
IntrusiveSharedPtr< T > & sleipnir::IntrusiveSharedPtr< T >::operator= ( const IntrusiveSharedPtr< T > & rhs)
inlineconstexprnoexcept

Makes a copy of the given intrusive shared pointer.

◆ operator=() [2/2]

template<typename T >
IntrusiveSharedPtr< T > & sleipnir::IntrusiveSharedPtr< T >::operator= ( IntrusiveSharedPtr< T > && rhs)
inlineconstexprnoexcept

Move assigns from the given intrusive shared pointer.

Friends And Related Symbol Documentation

◆ operator!= [1/3]

template<typename T >
bool operator!= ( const IntrusiveSharedPtr< T > & lhs,
const IntrusiveSharedPtr< T > & rhs )
friend

Returns true if the given intrusive shared pointers point to different objects.

◆ operator!= [2/3]

template<typename T >
bool operator!= ( const IntrusiveSharedPtr< T > & lhs,
std::nullptr_t  )
friend

Returns true if the left-hand intrusive shared pointer doesn't point to nullptr.

◆ operator!= [3/3]

template<typename T >
bool operator!= ( std::nullptr_t ,
const IntrusiveSharedPtr< T > & rhs )
friend

Returns true if the right-hand intrusive shared pointer doesn't point to nullptr.

◆ operator== [1/3]

template<typename T >
bool operator== ( const IntrusiveSharedPtr< T > & lhs,
const IntrusiveSharedPtr< T > & rhs )
friend

Returns true if the given intrusive shared pointers point to the same object.

◆ operator== [2/3]

template<typename T >
bool operator== ( const IntrusiveSharedPtr< T > & lhs,
std::nullptr_t  )
friend

Returns true if the left-hand intrusive shared pointer points to nullptr.

◆ operator== [3/3]

template<typename T >
bool operator== ( std::nullptr_t ,
const IntrusiveSharedPtr< T > & rhs )
friend

Returns true if the right-hand intrusive shared pointer points to nullptr.


The documentation for this class was generated from the following file: