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 213 of file MemoryX.h.

Constructor & Destructor Documentation

◆ ValueRestorer() [1/3]

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

Definition at line 218 of file MemoryX.h.

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

◆ ValueRestorer() [2/3]

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

Definition at line 221 of file MemoryX.h.

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

◆ ValueRestorer() [3/3]

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

Definition at line 224 of file MemoryX.h.

225 : 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 226 of file MemoryX.h.

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

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