Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::core::ScopedPtr< T, AllocationPolicy > Class Template Reference

Unique ownrship pointer. More...

#include <scoped_ptr.h>

Inheritance diagram for roc::core::ScopedPtr< T, AllocationPolicy >:
Collaboration diagram for roc::core::ScopedPtr< T, AllocationPolicy >:

Public Member Functions

 ScopedPtr ()
 Initialize null pointer. More...
 
 ScopedPtr (T *ptr, const AllocationPolicy &policy)
 Initialize from a raw pointer. More...
 
 ~ScopedPtr ()
 Destroy object. More...
 
void reset ()
 Reset pointer to null. More...
 
void reset (T *new_ptr, const AllocationPolicy &new_policy)
 Reset pointer to a new value. More...
 
T * release ()
 Get underlying pointer and pass ownership to the caller. More...
 
T * get () const
 Get underlying pointer. More...
 
T * operator-> () const
 Get underlying pointer. More...
 
T & operator* () const
 Get underlying reference. More...
 
 operator const struct unspecified_bool * () const
 Convert to bool. More...
 

Detailed Description

template<class T, class AllocationPolicy = ArenaAllocation>
class roc::core::ScopedPtr< T, AllocationPolicy >

Unique ownrship pointer.

Template Parameters
Tdefines pointee type. It may be const.
AllocationPolicydefies (de)allocation policy.

When ScopedPtr is destroyed or reset, it invokes AllocationPolicy::destroy() to destroy the owned object.

Definition at line 33 of file scoped_ptr.h.

Constructor & Destructor Documentation

◆ ScopedPtr() [1/2]

template<class T , class AllocationPolicy = ArenaAllocation>
roc::core::ScopedPtr< T, AllocationPolicy >::ScopedPtr ( )
inline

Initialize null pointer.

Definition at line 36 of file scoped_ptr.h.

◆ ScopedPtr() [2/2]

template<class T , class AllocationPolicy = ArenaAllocation>
roc::core::ScopedPtr< T, AllocationPolicy >::ScopedPtr ( T *  ptr,
const AllocationPolicy &  policy 
)
inline

Initialize from a raw pointer.

Definition at line 41 of file scoped_ptr.h.

◆ ~ScopedPtr()

template<class T , class AllocationPolicy = ArenaAllocation>
roc::core::ScopedPtr< T, AllocationPolicy >::~ScopedPtr ( )
inline

Destroy object.

Definition at line 47 of file scoped_ptr.h.

Member Function Documentation

◆ get()

template<class T , class AllocationPolicy = ArenaAllocation>
T* roc::core::ScopedPtr< T, AllocationPolicy >::get ( ) const
inline

Get underlying pointer.

Definition at line 84 of file scoped_ptr.h.

◆ operator const struct unspecified_bool *()

template<class T , class AllocationPolicy = ArenaAllocation>
roc::core::ScopedPtr< T, AllocationPolicy >::operator const struct unspecified_bool * ( ) const
inline

Convert to bool.

Definition at line 102 of file scoped_ptr.h.

◆ operator*()

template<class T , class AllocationPolicy = ArenaAllocation>
T& roc::core::ScopedPtr< T, AllocationPolicy >::operator* ( ) const
inline

Get underlying reference.

Definition at line 94 of file scoped_ptr.h.

◆ operator->()

template<class T , class AllocationPolicy = ArenaAllocation>
T* roc::core::ScopedPtr< T, AllocationPolicy >::operator-> ( ) const
inline

Get underlying pointer.

Definition at line 89 of file scoped_ptr.h.

◆ release()

template<class T , class AllocationPolicy = ArenaAllocation>
T* roc::core::ScopedPtr< T, AllocationPolicy >::release ( )
inline

Get underlying pointer and pass ownership to the caller.

Definition at line 71 of file scoped_ptr.h.

◆ reset() [1/2]

template<class T , class AllocationPolicy = ArenaAllocation>
void roc::core::ScopedPtr< T, AllocationPolicy >::reset ( )
inline

Reset pointer to null.

Definition at line 52 of file scoped_ptr.h.

◆ reset() [2/2]

template<class T , class AllocationPolicy = ArenaAllocation>
void roc::core::ScopedPtr< T, AllocationPolicy >::reset ( T *  new_ptr,
const AllocationPolicy &  new_policy 
)
inline

Reset pointer to a new value.

Definition at line 61 of file scoped_ptr.h.


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