KiCad PCB EDA Suite
|
RAII class that sets an value at construction and resets it to the original value at destruction. More...
#include <scoped_set_reset.h>
Public Member Functions | |
SCOPED_SET_RESET (VAL_TYPE &target, VAL_TYPE value) | |
~SCOPED_SET_RESET () | |
Destruct the class, and return the target to its original value. | |
Private Attributes | |
VAL_TYPE | m_original |
VAL_TYPE & | m_target |
RAII class that sets an value at construction and resets it to the original value at destruction.
int target = 0; SCOPED_SET_RESET( target, 42 );Instead, you can use a type alias, for example:
using SCOPED_INT_SET_RESET = SCOPED_SET_RESET<int>; int target = 0; SCOPED_INT_SET_RESET( target , 42 );
Definition at line 46 of file scoped_set_reset.h.
|
inline |
Definition at line 50 of file scoped_set_reset.h.
References SCOPED_SET_RESET< VAL_TYPE >::m_original, and SCOPED_SET_RESET< VAL_TYPE >::m_target.
|
inline |
Destruct the class, and return the target to its original value.
Definition at line 60 of file scoped_set_reset.h.
References SCOPED_SET_RESET< VAL_TYPE >::m_original, and SCOPED_SET_RESET< VAL_TYPE >::m_target.
|
private |
Definition at line 66 of file scoped_set_reset.h.
Referenced by SCOPED_SET_RESET< VAL_TYPE >::SCOPED_SET_RESET(), and SCOPED_SET_RESET< VAL_TYPE >::~SCOPED_SET_RESET().
|
private |
Definition at line 67 of file scoped_set_reset.h.
Referenced by SCOPED_SET_RESET< VAL_TYPE >::SCOPED_SET_RESET(), and SCOPED_SET_RESET< VAL_TYPE >::~SCOPED_SET_RESET().