KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SCOPED_SET_RESET< VAL_TYPE > Class Template Reference

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
 

Detailed Description

template<typename VAL_TYPE>
class SCOPED_SET_RESET< VAL_TYPE >

RAII class that sets an value at construction and resets it to the original value at destruction.

Note
There is no type deduction for template classes until C++17, \ so you can't do this:
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.

Constructor & Destructor Documentation

◆ SCOPED_SET_RESET()

template<typename VAL_TYPE >
SCOPED_SET_RESET< VAL_TYPE >::SCOPED_SET_RESET ( VAL_TYPE &  target,
VAL_TYPE  value 
)
inline

◆ ~SCOPED_SET_RESET()

template<typename VAL_TYPE >
SCOPED_SET_RESET< VAL_TYPE >::~SCOPED_SET_RESET ( )
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.

Member Data Documentation

◆ m_original

template<typename VAL_TYPE >
VAL_TYPE SCOPED_SET_RESET< VAL_TYPE >::m_original
private

◆ m_target

template<typename VAL_TYPE >
VAL_TYPE& SCOPED_SET_RESET< VAL_TYPE >::m_target
private

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