DirectZ
Loading...
Searching...
No Matches
dz::size_ptr< T > Struct Template Reference

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_ptroperator= (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.
Toperator-> ()
 Pointer access operator.
Toperator* ()
 Dereference operator.
const Tget () const
 Gets the raw pointer.
size_t get_size () const
 Gets the number of elements pointed to.

Public Attributes

Tptr = nullptr
size_t * size = nullptr
size_t * ref_c = nullptr
void(* deleter )(void *) = nullptr

Detailed Description

template<typename T>
struct dz::size_ptr< T >

A reference-counted smart pointer with associated size and custom deleter.

Template Parameters
TThe type of the object being pointed to.

Constructor & Destructor Documentation

◆ size_ptr() [1/3]

template<typename T>
dz::size_ptr< T >::size_ptr ( )
default

Default constructor.

◆ size_ptr() [2/3]

template<typename T>
dz::size_ptr< T >::size_ptr ( T * ptr,
size_t size = 1,
void(* deleter )(void *) = &default_delete_single::call<T> )
inline

Construct with data pointer, size, and deleter.

Parameters
ptrRaw pointer to the data.
sizeNumber of elements.
deleterDeleter function to call on destruction.

◆ size_ptr() [3/3]

template<typename T>
dz::size_ptr< T >::size_ptr ( const size_ptr< T > & other)
inline

Copy constructor (increments reference count).

Parameters
otherAnother size_ptr to copy from.

◆ ~size_ptr()

template<typename T>
dz::size_ptr< T >::~size_ptr ( )
inline

Destructor. Decrements reference count and frees if zero.

Member Function Documentation

◆ get()

template<typename T>
const T * dz::size_ptr< T >::get ( ) const
inline

Gets the raw pointer.

Returns
Const pointer to the data.

◆ get_size()

template<typename T>
size_t dz::size_ptr< T >::get_size ( ) const
inline

Gets the number of elements pointed to.

Returns
Size in elements.

◆ operator*()

template<typename T>
T & dz::size_ptr< T >::operator* ( )
inline

Dereference operator.

Returns
Reference to the data.

◆ operator->()

template<typename T>
T * dz::size_ptr< T >::operator-> ( )
inline

Pointer access operator.

Returns
Pointer to the data.

◆ operator=()

template<typename T>
size_ptr & dz::size_ptr< T >::operator= ( const size_ptr< T > & other)
inline

Copy assignment operator.

Parameters
otherAnother size_ptr to assign from.
Returns
Reference to this.

◆ reset()

template<typename T>
void dz::size_ptr< T >::reset ( )
inline

Reset the smart pointer, decrementing the reference count and deleting resources if needed.

Member Data Documentation

◆ deleter

template<typename T>
void(* dz::size_ptr< T >::deleter) (void *) = nullptr

Function pointer to the deleter function.

◆ ptr

template<typename T>
T* dz::size_ptr< T >::ptr = nullptr

Raw pointer to the data.

◆ ref_c

template<typename T>
size_t* dz::size_ptr< T >::ref_c = nullptr

Reference count shared among copies.

◆ size

template<typename T>
size_t* dz::size_ptr< T >::size = nullptr

Shared pointer to the size of the data.


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