HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
intrusive_ptr< T > Class Template Reference

A simple intrusive pointer, modeled after std::shared_ptr. More...

#include <refcnt.h>

Public Types

typedef T element_type
 

Public Member Functions

 intrusive_ptr () noexcept
 Default ctr. More...
 
 intrusive_ptr (T *ptr)
 
 intrusive_ptr (const intrusive_ptr &r)
 Construct from another intrusive_ptr. More...
 
 intrusive_ptr (intrusive_ptr &&r) noexcept
 Move construct from another intrusive_ptr. More...
 
 ~intrusive_ptr ()
 Destructor. More...
 
intrusive_ptroperator= (const intrusive_ptr &r)
 Assign from intrusive_ptr. More...
 
intrusive_ptroperator= (intrusive_ptr &&r) noexcept
 Move assignment from intrusive_ptr. More...
 
void reset () noexcept
 Reset to null reference. More...
 
void reset (T *r)
 Reset to point to a pointer. More...
 
Trelease ()
 
void swap (intrusive_ptr &r) noexcept
 Swap intrusive pointers. More...
 
Toperator* () const
 Dereference. More...
 
Toperator-> () const
 Dereference. More...
 
Tget () const noexcept
 Get raw pointer. More...
 
 operator bool () const noexcept
 Cast to bool to detect whether it points to anything. More...
 

Friends

bool operator== (const intrusive_ptr &a, const T *b)
 
bool operator== (const T *b, const intrusive_ptr &a)
 

Detailed Description

template<class T>
class intrusive_ptr< T >

A simple intrusive pointer, modeled after std::shared_ptr.

Definition at line 28 of file refcnt.h.

Member Typedef Documentation

template<class T >
typedef T intrusive_ptr< T >::element_type

Definition at line 30 of file refcnt.h.

Constructor & Destructor Documentation

template<class T >
intrusive_ptr< T >::intrusive_ptr ( )
inlinenoexcept

Default ctr.

Definition at line 33 of file refcnt.h.

template<class T >
intrusive_ptr< T >::intrusive_ptr ( T ptr)
inline

Construct from a raw pointer (presumed to be just now allocated, and now owned by us).

Definition at line 40 of file refcnt.h.

template<class T >
intrusive_ptr< T >::intrusive_ptr ( const intrusive_ptr< T > &  r)
inline

Construct from another intrusive_ptr.

Definition at line 48 of file refcnt.h.

template<class T >
intrusive_ptr< T >::intrusive_ptr ( intrusive_ptr< T > &&  r)
inlinenoexcept

Move construct from another intrusive_ptr.

Definition at line 56 of file refcnt.h.

template<class T >
intrusive_ptr< T >::~intrusive_ptr ( )
inline

Destructor.

Definition at line 63 of file refcnt.h.

Member Function Documentation

template<class T >
T* intrusive_ptr< T >::get ( ) const
inlinenoexcept

Get raw pointer.

Definition at line 148 of file refcnt.h.

template<class T >
intrusive_ptr< T >::operator bool ( ) const
inlinenoexcept

Cast to bool to detect whether it points to anything.

Definition at line 151 of file refcnt.h.

template<class T >
T& intrusive_ptr< T >::operator* ( ) const
inline

Dereference.

Definition at line 134 of file refcnt.h.

template<class T >
T* intrusive_ptr< T >::operator-> ( ) const
inline

Dereference.

Definition at line 141 of file refcnt.h.

template<class T >
intrusive_ptr& intrusive_ptr< T >::operator= ( const intrusive_ptr< T > &  r)
inline

Assign from intrusive_ptr.

Definition at line 70 of file refcnt.h.

template<class T >
intrusive_ptr& intrusive_ptr< T >::operator= ( intrusive_ptr< T > &&  r)
inlinenoexcept

Move assignment from intrusive_ptr.

Definition at line 77 of file refcnt.h.

template<class T >
T* intrusive_ptr< T >::release ( )
inline

Set this smart pointer to null, decrement the object's reference count, return the original raw pointer, but do NOT delete the object even if the ref count goes to zero. The only safe use case is to convert the sole managed pointer to an object into a raw pointer. DANGER – use with caution! This is only safe to do if no other intrusive_ptr refers to the object (such a pointer may subsequently reset, decrementing the count to 0, and incorrectly free the object), and it can cause a memory leak if the caller isn't careful to either reassign the returned pointer to another managed pointer or delete it manually.

Definition at line 114 of file refcnt.h.

template<class T >
void intrusive_ptr< T >::reset ( )
inlinenoexcept

Reset to null reference.

Definition at line 84 of file refcnt.h.

template<class T >
void intrusive_ptr< T >::reset ( T r)
inline

Reset to point to a pointer.

Definition at line 93 of file refcnt.h.

template<class T >
void intrusive_ptr< T >::swap ( intrusive_ptr< T > &  r)
inlinenoexcept

Swap intrusive pointers.

Definition at line 126 of file refcnt.h.

Friends And Related Function Documentation

template<class T >
bool operator== ( const intrusive_ptr< T > &  a,
const T b 
)
friend

Definition at line 153 of file refcnt.h.

template<class T >
bool operator== ( const T b,
const intrusive_ptr< T > &  a 
)
friend

Definition at line 157 of file refcnt.h.


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