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...
 

Detailed Description

template<class T>
class intrusive_ptr< T >

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

Definition at line 53 of file refcnt.h.

Member Typedef Documentation

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

Definition at line 55 of file refcnt.h.

Constructor & Destructor Documentation

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

Default ctr.

Definition at line 58 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 65 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 73 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 81 of file refcnt.h.

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

Destructor.

Definition at line 88 of file refcnt.h.

Member Function Documentation

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

Get raw pointer.

Definition at line 173 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 176 of file refcnt.h.

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

Dereference.

Definition at line 159 of file refcnt.h.

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

Dereference.

Definition at line 166 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 95 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 102 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 139 of file refcnt.h.

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

Reset to null reference.

Definition at line 109 of file refcnt.h.

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

Reset to point to a pointer.

Definition at line 118 of file refcnt.h.

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

Swap intrusive pointers.

Definition at line 151 of file refcnt.h.


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