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

Pointer wrapper that may borrow or own the pointee. More...

#include <src/utility.h>

Public Types

using const_pointer = element_type const *
 Const pointer type exposed by the pointer wrapper.
 
using const_reference = element_type const &
 Const reference type exposed by the pointer wrapper.
 
using element_type = T
 Object type referenced by the pointer wrapper.
 
using pointer = element_type *
 Mutable pointer type exposed by the pointer wrapper.
 
using reference = element_type &
 Mutable reference type exposed by the pointer wrapper.
 

Public Member Functions

reference operator* ()
 Dereference the wrapped pointer.
 
const_reference operator* () const
 Dereference the wrapped pointer.
 
pointer operator-> ()
 Access members of the wrapped pointer.
 
const_pointer operator-> () const
 Access members of the wrapped pointer.
 
wrap_ptroperator= (pointer p)
 Assign state from another instance while preserving ownership semantics.
 
template<class V >
wrap_ptroperator= (std::unique_ptr< V > &&uniq_ptr)
 Assign state from another instance while preserving ownership semantics.
 
wrap_ptroperator= (wrap_ptr &&other) noexcept
 Assign state from another instance while preserving ownership semantics.
 
 wrap_ptr (pointer p)
 Construct an owning or non-owning wrapper around a raw pointer.
 
 wrap_ptr (std::unique_ptr< element_type > &&uniq_p)
 Construct an owning or non-owning wrapper around a raw pointer.
 
 wrap_ptr (wrap_ptr &&other)
 Construct an owning or non-owning wrapper around a raw pointer.
 

Detailed Description

template<class T>
class util::wrap_ptr< T >

Pointer wrapper that may borrow or own the pointee.

Constructor & Destructor Documentation

◆ wrap_ptr() [1/3]

template<class T >
util::wrap_ptr< T >::wrap_ptr ( pointer p)
inline

Construct an owning or non-owning wrapper around a raw pointer.

Parameters
pPointer passed to the deleter or conversion helper.

◆ wrap_ptr() [2/3]

template<class T >
util::wrap_ptr< T >::wrap_ptr ( std::unique_ptr< element_type > && uniq_p)
inline

Construct an owning or non-owning wrapper around a raw pointer.

Parameters
uniq_pUniq p.

◆ wrap_ptr() [3/3]

template<class T >
util::wrap_ptr< T >::wrap_ptr ( wrap_ptr< T > && other)
inline

Construct an owning or non-owning wrapper around a raw pointer.

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

Member Function Documentation

◆ operator*() [1/2]

template<class T >
reference util::wrap_ptr< T >::operator* ( )
inline

Dereference the wrapped pointer.

Returns
Mutable reference to the pointed-to object.

◆ operator*() [2/2]

template<class T >
const_reference util::wrap_ptr< T >::operator* ( ) const
inline

Dereference the wrapped pointer.

Returns
Const reference to the pointed-to object.

◆ operator->() [1/2]

template<class T >
pointer util::wrap_ptr< T >::operator-> ( )
inline

Access members of the wrapped pointer.

Returns
Mutable pointer to the wrapped object.

◆ operator->() [2/2]

template<class T >
const_pointer util::wrap_ptr< T >::operator-> ( ) const
inline

Access members of the wrapped pointer.

Returns
Const pointer to the wrapped object.

◆ operator=() [1/3]

template<class T >
wrap_ptr & util::wrap_ptr< T >::operator= ( pointer p)
inline

Assign state from another instance while preserving ownership semantics.

Parameters
pPointer passed to the deleter or conversion helper.
Returns
Reference returned by the operator overload.

◆ operator=() [2/3]

template<class T >
template<class V >
wrap_ptr & util::wrap_ptr< T >::operator= ( std::unique_ptr< V > && uniq_ptr)
inline

Assign state from another instance while preserving ownership semantics.

Parameters
uniq_ptrUnique pointer whose ownership is transferred to the wrapper.
Returns
Reference returned by the operator overload.

◆ operator=() [3/3]

template<class T >
wrap_ptr & util::wrap_ptr< T >::operator= ( wrap_ptr< T > && 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.

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