#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_ptr & | operator= (intrusive_ptr &&rhs) |
intrusive_ptr & | operator= (intrusive_ptr const &rhs) |
intrusive_ptr & | operator= (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) |
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.