The Conley-Morse Graphs Software
Public Member Functions | Private Attributes | List of all members
local_value< T > Class Template Reference

Initializes the given variable with the value provided and restores the previous value at the end of the current block. More...

#include <utils.h>

Public Member Functions

 local_value (T &_variable, const T &_value)
 The only allowed constructor. More...
 
 ~local_value ()
 The destructor which restores the original value of the variable. More...
 

Private Attributes

T & variable
 A reference of the variable. More...
 
previous_value
 The original value of the variable. More...
 

Detailed Description

template<class T>
class local_value< T >

Initializes the given variable with the value provided and restores the previous value at the end of the current block.

The restoration of the previous value takes place upon destruction of this object. This action effects in a local value of a given variable valid in the current block only (e.g., until 'return').

Definition at line 108 of file utils.h.

Constructor & Destructor Documentation

◆ local_value()

template<class T >
local_value< T >::local_value ( T &  _variable,
const T &  _value 
)
inline

The only allowed constructor.

Definition at line 112 of file utils.h.

References local_value< T >::variable.

◆ ~local_value()

template<class T >
local_value< T >::~local_value ( )
inline

The destructor which restores the original value of the variable.

Definition at line 117 of file utils.h.

References local_value< T >::previous_value, and local_value< T >::variable.

Member Data Documentation

◆ previous_value

template<class T >
T local_value< T >::previous_value
private

The original value of the variable.

Definition at line 124 of file utils.h.

Referenced by local_value< T >::~local_value().

◆ variable

template<class T >
T& local_value< T >::variable
private

A reference of the variable.

Definition at line 121 of file utils.h.

Referenced by local_value< T >::local_value(), and local_value< T >::~local_value().


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