Audacity  3.0.3
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 331 of file MemoryX.h.

Constructor & Destructor Documentation

◆ ValueRestorer() [1/3]

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

Definition at line 336 of file MemoryX.h.

337  : std::unique_ptr< T, RestoreValue<T> >( &var, { var } )
338  {}

◆ ValueRestorer() [2/3]

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

Definition at line 339 of file MemoryX.h.

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

◆ ValueRestorer() [3/3]

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

Definition at line 342 of file MemoryX.h.

343  : 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 344 of file MemoryX.h.

345  {
346  if (this != &that)
347  std::unique_ptr < T, RestoreValue<T> >::operator=(std::move(that));
348  return *this;
349  }

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