mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
ccc6e69a29
I feel reasonably confident that I might have gotten these right. :^)
26 lines
341 B
C++
26 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;
|