DirectZ
|
A reference-counted smart pointer with associated size and custom deleter. More...
#include <size_ptr.hpp>
Public Member Functions | |
size_ptr ()=default | |
Default constructor. | |
size_ptr (T *ptr, size_t size=1, void(*deleter)(void *)=&default_delete_single::call< T >) | |
Construct with data pointer, size, and deleter. | |
size_ptr (const size_ptr &other) | |
Copy constructor (increments reference count). | |
size_ptr & | operator= (const size_ptr &other) |
Copy assignment operator. | |
~size_ptr () | |
Destructor. Decrements reference count and frees if zero. | |
void | reset () |
Reset the smart pointer, decrementing the reference count and deleting resources if needed. | |
T * | operator-> () |
Pointer access operator. | |
T & | operator* () |
Dereference operator. | |
const T * | get () const |
Gets the raw pointer. | |
size_t | get_size () const |
Gets the number of elements pointed to. |
Public Attributes | |
T * | ptr = nullptr |
size_t * | size = nullptr |
size_t * | ref_c = nullptr |
void(* | deleter )(void *) = nullptr |
A reference-counted smart pointer with associated size and custom deleter.
T | The type of the object being pointed to. |
|
default |
Default constructor.
|
inline |
Construct with data pointer, size, and deleter.
ptr | Raw pointer to the data. |
size | Number of elements. |
deleter | Deleter function to call on destruction. |
|
inline |
Copy constructor (increments reference count).
other | Another size_ptr to copy from. |
|
inline |
Destructor. Decrements reference count and frees if zero.
|
inline |
Gets the raw pointer.
|
inline |
Gets the number of elements pointed to.
|
inline |
Dereference operator.
|
inline |
Pointer access operator.
Copy assignment operator.
other | Another size_ptr to assign from. |
|
inline |
Reset the smart pointer, decrementing the reference count and deleting resources if needed.
void(* dz::size_ptr< T >::deleter) (void *) = nullptr |
Function pointer to the deleter function.
T* dz::size_ptr< T >::ptr = nullptr |
Raw pointer to the data.
size_t* dz::size_ptr< T >::ref_c = nullptr |
Reference count shared among copies.
size_t* dz::size_ptr< T >::size = nullptr |
Shared pointer to the size of the data.