The Battle for Wesnoth  1.17.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_

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,
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 ( )

Definition at line 38 of file guard_value.hpp.

References utils::guard_value< T >::old_val_.

Member Data Documentation

◆ old_val_

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

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_

Definition at line 25 of file guard_value.hpp.

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