Sleipnir C++ API
Loading...
Searching...
No Matches
sleipnir::IntrusiveSharedPtr< T > Class Template Reference

#include <sleipnir/util/IntrusiveSharedPtr.hpp>

Public Member Functions

constexpr IntrusiveSharedPtr () noexcept=default
 
constexpr IntrusiveSharedPtr (std::nullptr_t) noexcept
 
constexpr IntrusiveSharedPtr (T *ptr) noexcept
 
constexpr ~IntrusiveSharedPtr ()
 
constexpr IntrusiveSharedPtr (const IntrusiveSharedPtr< T > &rhs) noexcept
 
template<typename U >
requires (!std::same_as<T, U> && std::convertible_to<U*, T*>)
constexpr IntrusiveSharedPtr (const IntrusiveSharedPtr< U > &rhs) noexcept
 
constexpr IntrusiveSharedPtr< T > & operator= (const IntrusiveSharedPtr< T > &rhs) noexcept
 
template<typename U >
requires (!std::same_as<T, U> && std::convertible_to<U*, T*>)
constexpr IntrusiveSharedPtr< T > & operator= (const IntrusiveSharedPtr< U > &rhs) noexcept
 
constexpr IntrusiveSharedPtr (IntrusiveSharedPtr< T > &&rhs) noexcept
 
template<typename U >
requires (!std::same_as<T, U> && std::convertible_to<U*, T*>)
constexpr IntrusiveSharedPtr (IntrusiveSharedPtr< U > &&rhs) noexcept
 
constexpr IntrusiveSharedPtr< T > & operator= (IntrusiveSharedPtr< T > &&rhs) noexcept
 
template<typename U >
requires (!std::same_as<T, U> && std::convertible_to<U*, T*>)
constexpr IntrusiveSharedPtr< T > & operator= (IntrusiveSharedPtr< U > &&rhs) noexcept
 
constexpr T * Get () const noexcept
 
constexpr T & operator* () const noexcept
 
constexpr T * operator-> () const noexcept
 
constexpr operator bool () const noexcept
 

Friends

template<typename >
class IntrusiveSharedPtr
 
constexpr bool operator== (const IntrusiveSharedPtr< T > &lhs, const IntrusiveSharedPtr< T > &rhs) noexcept
 
constexpr bool operator!= (const IntrusiveSharedPtr< T > &lhs, const IntrusiveSharedPtr< T > &rhs) noexcept
 
constexpr bool operator== (const IntrusiveSharedPtr< T > &lhs, std::nullptr_t) noexcept
 
constexpr bool operator== (std::nullptr_t, const IntrusiveSharedPtr< T > &rhs) noexcept
 
constexpr bool operator!= (const IntrusiveSharedPtr< T > &lhs, std::nullptr_t) noexcept
 
constexpr bool operator!= (std::nullptr_t, const IntrusiveSharedPtr< T > &rhs) noexcept
 

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/7]

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

Constructs an empty intrusive shared pointer.

◆ IntrusiveSharedPtr() [2/7]

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

Constructs an empty intrusive shared pointer.

◆ IntrusiveSharedPtr() [3/7]

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

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

◆ ~IntrusiveSharedPtr()

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

◆ IntrusiveSharedPtr() [4/7]

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

Copy constructs from the given intrusive shared pointer.

◆ IntrusiveSharedPtr() [5/7]

template<typename T >
template<typename U >
requires (!std::same_as<T, U> && std::convertible_to<U*, T*>)
constexpr sleipnir::IntrusiveSharedPtr< T >::IntrusiveSharedPtr ( const IntrusiveSharedPtr< U > &  rhs)
inlineconstexprnoexcept

Copy constructs from the given intrusive shared pointer.

◆ IntrusiveSharedPtr() [6/7]

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

Move constructs from the given intrusive shared pointer.

◆ IntrusiveSharedPtr() [7/7]

template<typename T >
template<typename U >
requires (!std::same_as<T, U> && std::convertible_to<U*, T*>)
constexpr sleipnir::IntrusiveSharedPtr< T >::IntrusiveSharedPtr ( IntrusiveSharedPtr< U > &&  rhs)
inlineconstexprnoexcept

Move constructs from the given intrusive shared pointer.

Member Function Documentation

◆ Get()

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

Returns the internal pointer.

◆ operator bool()

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

Returns true if the internal pointer isn't nullptr.

◆ operator*()

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

Returns the object pointed to by the internal pointer.

◆ operator->()

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

Returns the internal pointer.

◆ operator=() [1/4]

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

Makes a copy of the given intrusive shared pointer.

◆ operator=() [2/4]

template<typename T >
template<typename U >
requires (!std::same_as<T, U> && std::convertible_to<U*, T*>)
constexpr IntrusiveSharedPtr< T > & sleipnir::IntrusiveSharedPtr< T >::operator= ( const IntrusiveSharedPtr< U > &  rhs)
inlineconstexprnoexcept

Makes a copy of the given intrusive shared pointer.

◆ operator=() [3/4]

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

Move assigns from the given intrusive shared pointer.

◆ operator=() [4/4]

template<typename T >
template<typename U >
requires (!std::same_as<T, U> && std::convertible_to<U*, T*>)
constexpr IntrusiveSharedPtr< T > & sleipnir::IntrusiveSharedPtr< T >::operator= ( IntrusiveSharedPtr< U > &&  rhs)
inlineconstexprnoexcept

Move assigns from the given intrusive shared pointer.

Friends And Related Symbol Documentation

◆ IntrusiveSharedPtr

template<typename T >
template<typename >
friend class IntrusiveSharedPtr
friend

◆ operator!= [1/3]

template<typename T >
constexpr 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 >
constexpr 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 >
constexpr 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 >
constexpr 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 >
constexpr 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 >
constexpr 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: