Audacity 3.2.0
Public Member Functions | List of all members
ValueRestorer< T > Class Template Reference

Set a variable temporarily in a scope. More...

#include <MemoryX.h>

Inheritance diagram for ValueRestorer< T >:
[legend]
Collaboration diagram for ValueRestorer< T >:
[legend]

Public Member Functions

 ValueRestorer (T &var)
 
 ValueRestorer (T &var, const T &newValue)
 
 ValueRestorer (ValueRestorer &&that)
 
ValueRestoreroperator= (ValueRestorer &&that)
 

Detailed Description

template<typename T>
class ValueRestorer< T >

Set a variable temporarily in a scope.

Definition at line 210 of file MemoryX.h.

Constructor & Destructor Documentation

◆ ValueRestorer() [1/3]

template<typename T >
ValueRestorer< T >::ValueRestorer ( T &  var)
inlineexplicit

Definition at line 215 of file MemoryX.h.

216 : std::unique_ptr< T, RestoreValue<T> >( &var, { var } )
217 {}

◆ ValueRestorer() [2/3]

template<typename T >
ValueRestorer< T >::ValueRestorer ( T &  var,
const T &  newValue 
)
inlineexplicit

Definition at line 218 of file MemoryX.h.

219 : std::unique_ptr< T, RestoreValue<T> >( &var, { var } )
220 { var = newValue; }

◆ ValueRestorer() [3/3]

template<typename T >
ValueRestorer< T >::ValueRestorer ( ValueRestorer< T > &&  that)
inline

Definition at line 221 of file MemoryX.h.

222 : std::unique_ptr < T, RestoreValue<T> > ( std::move(that) ) {};

Member Function Documentation

◆ operator=()

template<typename T >
ValueRestorer & ValueRestorer< T >::operator= ( ValueRestorer< T > &&  that)
inline

Definition at line 223 of file MemoryX.h.

224 {
225 if (this != &that)
226 std::unique_ptr < T, RestoreValue<T> >::operator=(std::move(that));
227 return *this;
228 }

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