AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
aui::ptr Struct Reference

Static Public Member Functions

template<typename T , typename Deleter = std::default_delete<T>>
static _unique< T, Deleter > make_unique_with_deleter (T *ptr, Deleter deleter=Deleter{})
 Creates unique_ptr from raw pointer and a deleter. More...
 
template<typename T >
static _< T > manage (T *raw)
 
template<typename T , typename Deleter >
static _< T > manage (T *raw, Deleter deleter)
 
template<typename T >
static _unique< T > unique (T *raw)
 
template<typename T >
static _< T > fake (T *raw)
 

Member Function Documentation

◆ fake()

template<typename T >
_< T > aui::ptr::fake ( T *  raw)
static

Creates fake shared pointer to T* raw with empty destructor, which does nothing. It's useful when some function accept shared pointer but you have only raw one.

Template Parameters
Tany type
Parameters
rawraw pointer to manage memory of
Returns
shared pointer

◆ make_unique_with_deleter()

template<typename T , typename Deleter = std::default_delete<T>>
static _unique< T, Deleter > aui::ptr::make_unique_with_deleter ( T *  ptr,
Deleter  deleter = Deleter{} 
)
inlinestatic

Creates unique_ptr from raw pointer and a deleter.

unique_ptr could not deduce T and Deleter by itself. Use this function to avoid this restriction. By using this function, lifetime of the pointer is delegated to std::unique_ptr. The wrapped pointer will be freed by specified Deleter. Default deleter is std::default_delete. You may want to specialize std::default_delete<T> struct in order to specify default deleter for T, in this case you can omit deleter argument of this function.

◆ manage() [1/2]

template<typename T >
_< T > aui::ptr::manage ( T *  raw)
static

Delegates memory management of the raw pointer T* raw to the shared pointer, which is returned

Template Parameters
Tany type
Parameters
rawraw pointer to manage memory of
Returns
shared pointer

◆ manage() [2/2]

template<typename T , typename Deleter >
_< T > aui::ptr::manage ( T *  raw,
Deleter  deleter 
)
static

Delegates memory management of the raw pointer T* raw to the shared pointer, which is returned

Template Parameters
Tany type
Deleterobject implementing operator()(T*)
Parameters
rawraw pointer to manage memory of
deleter
Returns
shared pointer

◆ unique()

template<typename T >
_unique< T > aui::ptr::unique ( T *  raw)
static

Delegates memory management of the raw pointer T* raw to the unique pointer, which is returned

Template Parameters
Tany type
Parameters
rawraw pointer to manage memory of
Returns
unique pointer

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