HDK
|
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_ptr & | operator= (const intrusive_ptr &r) |
Assign from intrusive_ptr. More... | |
intrusive_ptr & | operator= (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... | |
T * | release () |
void | swap (intrusive_ptr &r) noexcept |
Swap intrusive pointers. More... | |
T & | operator* () const |
Dereference. More... | |
T * | operator-> () const |
Dereference. More... | |
T * | get () 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) |
A simple intrusive pointer, modeled after std::shared_ptr.
typedef T intrusive_ptr< T >::element_type |
|
inlinenoexcept |
|
inline |
|
inline |
Construct from another intrusive_ptr.
|
inlinenoexcept |
Move construct from another intrusive_ptr.
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
Assign from intrusive_ptr.
|
inlinenoexcept |
Move assignment from intrusive_ptr.
|
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.
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
friend |
|
friend |