Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZStd::intrusive_ptr< T > Class Template Reference

#include <intrusive_ptr.h>

Public Types

typedef T element_type
 
typedef T value_type
 
typedef T *this_type::* unspecified_bool_type
 

Public Member Functions

 intrusive_ptr (T *p)
 
template<class U >
 intrusive_ptr (intrusive_ptr< U > const &rhs, enable_if_t< is_convertible< U *, T * >::value, int >=0)
 
 intrusive_ptr (intrusive_ptr const &rhs)
 
template<class U >
enable_if_t< is_convertible< U *, T * >::value, intrusive_ptr & > operator= (intrusive_ptr< U > const &rhs)
 
template<class U >
 intrusive_ptr (intrusive_ptr< U > &&rhs, enable_if_t< is_convertible< U *, T * >::value, int >=0)
 
 intrusive_ptr (intrusive_ptr &&rhs)
 
template<class U >
enable_if_t< is_convertible< U *, T * >::value, intrusive_ptr & > operator= (intrusive_ptr< U > &&rhs)
 
intrusive_ptroperator= (intrusive_ptr &&rhs)
 
intrusive_ptroperator= (intrusive_ptr const &rhs)
 
intrusive_ptroperator= (T *rhs)
 
void reset ()
 
void reset (T *rhs)
 
T * get () const
 
T & operator* () const
 
T * operator-> () const
 
 operator unspecified_bool_type () const
 
bool operator! () const
 
void swap (intrusive_ptr &rhs)
 

Detailed Description

template<class T>
class AZStd::intrusive_ptr< T >

intrusive_ptr

A smart pointer that uses intrusive reference counting.

This pointer is not part of the C++ standard yet. It is considered AZStd extension. It extends the boost implementation.

There are many benefits in using intrusive reference counting. They are the recommended pointer in performance critical systems. The reason for that is you can control: no allocation occurs (counter is internal), you control the size of ref count, you know if it needs to be atomic or not, better cache coherency, you can convert back and forth to raw pointer, etc.

For all other cases shared_ptr is recommended. In shared pointer if you use make_shared/allocate_shared you will save the second allocation too.


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