Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
util::uniq_ptr< T, D > Class Template Reference

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

#include <src/utility.h>

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_type & get_deleter ()
 Return the deleter used when resetting the wrapped pointer.
const deleter_type & get_deleter () const
 Return the deleter used when resetting the wrapped pointer.
 operator bool () const
 Check whether the wrapper currently owns a non-null pointer.
pointer * operator& ()
 Expose the stored pointer address for C APIs that write handles.
pointer * operator& () const
 Expose the stored pointer address for C APIs that write handles.
std::add_lvalue_reference_t< element_type > operator* ()
 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_ptr & operator= (const uniq_ptr &other) noexcept=delete
template<class V>
uniq_ptr & operator= (std::unique_ptr< V, deleter_type > &&uniq) noexcept
 Assign state from another instance while preserving ownership semantics.
template<class V>
uniq_ptr & operator= (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.
constexpr uniq_ptr () noexcept=default
 Initialize an empty unique ownership wrapper.
 uniq_ptr (const uniq_ptr &other) noexcept=delete
constexpr uniq_ptr (std::nullptr_t) noexcept
 Construct an empty wrapper implicitly from nullptr, matching std::unique_ptr.
template<class V>
 uniq_ptr (std::unique_ptr< V, deleter_type > &&uniq) noexcept
 Transfer compatible standard unique-pointer ownership implicitly.
template<class V>
 uniq_ptr (uniq_ptr< V, deleter_type > &&other) noexcept
 Transfer compatible Sunshine unique-pointer ownership implicitly.
template<class V>
 uniq_ptr (V *p) noexcept
 Explicitly construct a unique ownership wrapper.

Protected Attributes

deleter_type _deleter
 Callable used to release _p.
pointer _p {nullptr}
 Pointer currently owned by the wrapper, initially empty.

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)
inlineexplicitnoexcept

Explicitly 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

Transfer compatible standard unique-pointer ownership implicitly.

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

Transfer compatible Sunshine unique-pointer ownership implicitly.

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: