The Battle for Wesnoth  1.15.12+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 23 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 31 of file guard_value.hpp.

◆ ~guard_value()

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

Definition at line 37 of file guard_value.hpp.

Member Data Documentation

◆ old_val_

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

◆ ref_

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

Definition at line 24 of file guard_value.hpp.


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