The Battle for Wesnoth  1.19.0-dev
Public Member Functions | Private Attributes | List of all members
utils::guard_value< T > Class Template Reference

Data-based RAII scope guard. More...

#include <guard_value.hpp>

Public Member Functions

 guard_value (T &ref, T new_val)
 
 ~guard_value ()
 

Private Attributes

T * ref_
 
old_val_
 

Detailed Description

template<typename T>
class utils::guard_value< T >

Data-based RAII scope guard.

Assigns a value to a specific location, then restores the old value once it goes out of scope.

Definition at line 24 of file guard_value.hpp.

Constructor & Destructor Documentation

◆ guard_value()

template<typename T >
utils::guard_value< T >::guard_value ( T &  ref,
new_val 
)
inline
Parameters
refThe memory location being guarded
new_valThe new value to temporarily assign to that location

Definition at line 32 of file guard_value.hpp.

◆ ~guard_value()

template<typename T >
utils::guard_value< T >::~guard_value ( )
inline

Member Data Documentation

◆ old_val_

template<typename T >
T utils::guard_value< T >::old_val_
private

Definition at line 26 of file guard_value.hpp.

Referenced by utils::guard_value< T >::~guard_value().

◆ ref_

template<typename T >
T* utils::guard_value< T >::ref_
private

Definition at line 25 of file guard_value.hpp.

Referenced by utils::guard_value< T >::~guard_value().


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