MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::Restore< T > Class Template Reference

RAII guard that restores ref to its current value at the end of the scope. More...

#include <mim/util/util.h>

Public Member Functions

 Restore (T &ref)
 Saves ref and restores it in the destructor.
 Restore (T &ref, T value)
 Saves ref, sets it to value, and restores the saved value in the destructor.
 ~Restore ()
 Restore (const Restore &)=delete
Restoreoperator= (const Restore &)=delete

Detailed Description

template<class T>
class mim::Restore< T >

RAII guard that restores ref to its current value at the end of the scope.

The two-argument constructor additionally sets ref to value up front (like std::exchange).

Definition at line 177 of file util.h.

Constructor & Destructor Documentation

◆ Restore() [1/3]

template<class T>
mim::Restore< T >::Restore ( T & ref)
inlineexplicit

Saves ref and restores it in the destructor.

Definition at line 180 of file util.h.

Referenced by operator=(), and Restore().

◆ Restore() [2/3]

template<class T>
mim::Restore< T >::Restore ( T & ref,
T value )
inline

Saves ref, sets it to value, and restores the saved value in the destructor.

Definition at line 185 of file util.h.

◆ ~Restore()

template<class T>
mim::Restore< T >::~Restore ( )
inline

Definition at line 189 of file util.h.

◆ Restore() [3/3]

template<class T>
mim::Restore< T >::Restore ( const Restore< T > & )
delete

References Restore().

Member Function Documentation

◆ operator=()

template<class T>
Restore & mim::Restore< T >::operator= ( const Restore< T > & )
delete

References Restore().


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