Sunshine master
Self-hosted game stream host for Moonlight.
util::uniq_ptr< T, D > Class Template Reference

Unique pointer wrapper with customizable pointer and deleter types. More...

#include <src/utility.h>

Inheritance diagram for util::uniq_ptr< T, D >:
[legend]

Public Types

using const_pointer = element_type const *
 Const pointer type exposed by the unique pointer wrapper.
 
using deleter_type = D
 Callable type used to release the managed pointer.
 
using element_type = T
 Object type managed by the unique pointer wrapper.
 
using pointer = element_type *
 Pointer type stored by the unique pointer wrapper.
 

Public Member Functions

pointer get ()
 Return the currently wrapped value or handle.
 
const_pointer get () const
 Return the currently wrapped value or handle.
 
deleter_typeget_deleter ()
 Return the deleter used when resetting the wrapped pointer.
 
const deleter_typeget_deleter () const
 Return the deleter used when resetting the wrapped pointer.
 
 operator bool () const
 Check whether the wrapper currently owns a non-null pointer.
 
pointeroperator& ()
 Expose the stored pointer address for C APIs that write handles.
 
pointeroperator& () const
 Expose the stored pointer address for C APIs that write handles.
 
std::add_lvalue_reference_t< element_typeoperator* ()
 Dereference the managed pointer.
 
std::add_lvalue_reference_t< element_type const > operator* () const
 Dereference the managed pointer.
 
pointer operator-> ()
 Access members of the managed pointer.
 
const_pointer operator-> () const
 Access members of the managed pointer.
 
uniq_ptroperator= (const uniq_ptr &other) noexcept=delete
 
template<class V >
uniq_ptroperator= (std::unique_ptr< V, deleter_type > &&uniq) noexcept
 Assign state from another instance while preserving ownership semantics.
 
template<class V >
uniq_ptroperator= (uniq_ptr< V, deleter_type > &&other) noexcept
 Assign state from another instance while preserving ownership semantics.
 
pointer release ()
 Release the COM or platform reference owned by the pointer.
 
void reset (pointer p=pointer())
 Reset the object to its initial empty state.
 
 uniq_ptr (const uniq_ptr &other) noexcept=delete
 
constexpr uniq_ptr (std::nullptr_t) noexcept
 Construct a unique ownership wrapper.
 
template<class V >
 uniq_ptr (std::unique_ptr< V, deleter_type > &&uniq) noexcept
 Construct a unique ownership wrapper.
 
template<class V >
 uniq_ptr (uniq_ptr< V, deleter_type > &&other) noexcept
 Construct a unique ownership wrapper.
 
template<class V >
 uniq_ptr (V *p) noexcept
 Construct a unique ownership wrapper.
 

Protected Attributes

deleter_type _deleter
 Callable used to release _p.
 
pointer _p
 Pointer currently owned by the wrapper.
 

Detailed Description

template<typename T, typename D = std::default_delete<T>>
class util::uniq_ptr< T, D >

Unique pointer wrapper with customizable pointer and deleter types.

Constructor & Destructor Documentation

◆ uniq_ptr() [1/3]

template<typename T , typename D = std::default_delete<T>>
template<class V >
util::uniq_ptr< T, D >::uniq_ptr ( V * p)
inlinenoexcept

Construct a unique ownership wrapper.

Parameters
pPointer passed to the deleter or conversion helper.

◆ uniq_ptr() [2/3]

template<typename T , typename D = std::default_delete<T>>
template<class V >
util::uniq_ptr< T, D >::uniq_ptr ( std::unique_ptr< V, deleter_type > && uniq)
inlinenoexcept

Construct a unique ownership wrapper.

Parameters
uniqUnique pointer whose owned value is transferred.

◆ uniq_ptr() [3/3]

template<typename T , typename D = std::default_delete<T>>
template<class V >
util::uniq_ptr< T, D >::uniq_ptr ( uniq_ptr< V, deleter_type > && other)
inlinenoexcept

Construct a unique ownership wrapper.

Parameters
otherSource object whose state is copied or moved into this object.

Member Function Documentation

◆ get() [1/2]

template<typename T , typename D = std::default_delete<T>>
pointer util::uniq_ptr< T, D >::get ( )
inline

Return the currently wrapped value or handle.

Returns
Underlying native handle or object pointer.

◆ get() [2/2]

template<typename T , typename D = std::default_delete<T>>
const_pointer util::uniq_ptr< T, D >::get ( ) const
inline

Return the currently wrapped value or handle.

Returns
Underlying native handle or object pointer.

◆ get_deleter() [1/2]

template<typename T , typename D = std::default_delete<T>>
deleter_type & util::uniq_ptr< T, D >::get_deleter ( )
inline

Return the deleter used when resetting the wrapped pointer.

Returns
Mutable deleter stored by the wrapper.

◆ get_deleter() [2/2]

template<typename T , typename D = std::default_delete<T>>
const deleter_type & util::uniq_ptr< T, D >::get_deleter ( ) const
inline

Return the deleter used when resetting the wrapped pointer.

Returns
Const deleter stored by the wrapper.

◆ operator&() [1/2]

template<typename T , typename D = std::default_delete<T>>
pointer * util::uniq_ptr< T, D >::operator& ( )
inline

Expose the stored pointer address for C APIs that write handles.

Returns
Address of the stored pointer.

◆ operator&() [2/2]

template<typename T , typename D = std::default_delete<T>>
pointer * util::uniq_ptr< T, D >::operator& ( ) const
inline

Expose the stored pointer address for C APIs that write handles.

Returns
Address of the stored pointer.

◆ operator*() [1/2]

template<typename T , typename D = std::default_delete<T>>
std::add_lvalue_reference_t< element_type > util::uniq_ptr< T, D >::operator* ( )
inline

Dereference the managed pointer.

Returns
Mutable reference to the pointed-to object.

◆ operator*() [2/2]

template<typename T , typename D = std::default_delete<T>>
std::add_lvalue_reference_t< element_type const > util::uniq_ptr< T, D >::operator* ( ) const
inline

Dereference the managed pointer.

Returns
Const reference to the pointed-to object.

◆ operator->() [1/2]

template<typename T , typename D = std::default_delete<T>>
pointer util::uniq_ptr< T, D >::operator-> ( )
inline

Access members of the managed pointer.

Returns
Mutable pointer to the managed object.

◆ operator->() [2/2]

template<typename T , typename D = std::default_delete<T>>
const_pointer util::uniq_ptr< T, D >::operator-> ( ) const
inline

Access members of the managed pointer.

Returns
Const pointer to the managed object.

◆ operator=() [1/2]

template<typename T , typename D = std::default_delete<T>>
template<class V >
uniq_ptr & util::uniq_ptr< T, D >::operator= ( std::unique_ptr< V, deleter_type > && uniq)
inlinenoexcept

Assign state from another instance while preserving ownership semantics.

Parameters
uniqUnique pointer whose owned value is transferred.
Returns
Reference returned by the operator overload.

◆ operator=() [2/2]

template<typename T , typename D = std::default_delete<T>>
template<class V >
uniq_ptr & util::uniq_ptr< T, D >::operator= ( uniq_ptr< V, deleter_type > && other)
inlinenoexcept

Assign state from another instance while preserving ownership semantics.

Parameters
otherSource object whose state is copied or moved into this object.
Returns
Reference returned by the operator overload.

◆ release()

template<typename T , typename D = std::default_delete<T>>
pointer util::uniq_ptr< T, D >::release ( )
inline

Release the COM or platform reference owned by the pointer.

Returns
Reference count or status returned after releasing the object.

◆ reset()

template<typename T , typename D = std::default_delete<T>>
void util::uniq_ptr< T, D >::reset ( pointer p = pointer())
inline

Reset the object to its initial empty state.

Parameters
pPointer passed to the deleter or conversion helper.

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