mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
27 lines
341 B
C
27 lines
341 B
C
|
#pragma once
|
||
|
|
||
|
namespace AK {
|
||
|
|
||
|
template<typename T>
|
||
|
class ValueRestorer {
|
||
|
public:
|
||
|
ValueRestorer(T& variable)
|
||
|
: m_variable(variable)
|
||
|
, m_saved_value(variable)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
~ValueRestorer()
|
||
|
{
|
||
|
m_variable = m_saved_value;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
T& m_variable;
|
||
|
T m_saved_value;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
using AK::ValueRestorer;
|