|
OpenTTD Source
14.0-beta3
|
Class to backup a specific variable and restore it upon destruction of this object to prevent stack values going out of scope before resetting the global to its original value. More...
#include <backup_type.hpp>
Public Member Functions | |
| AutoRestoreBackup (T &original, T new_value) | |
| Backup variable and switch to new value. More... | |
| ~AutoRestoreBackup () | |
| Restore the variable upon object destruction. | |
Private Member Functions | |
| AutoRestoreBackup (const AutoRestoreBackup &)=delete | |
| AutoRestoreBackup & | operator= (AutoRestoreBackup &)=delete |
Static Private Member Functions | |
| static void * | operator new (std::size_t)=delete |
| static void * | operator new[] (std::size_t)=delete |
Private Attributes | |
| T & | original |
| T | original_value |
Class to backup a specific variable and restore it upon destruction of this object to prevent stack values going out of scope before resetting the global to its original value.
Contrary to Backup this restores the variable automatically and there is no manual option to restore.
Definition at line 153 of file backup_type.hpp.
|
inline |
Backup variable and switch to new value.
| original | Variable to backup. |
| new_value | New value for variable. |
Definition at line 165 of file backup_type.hpp.