ladybird/AK/ValueRestorer.h
Andreas Kling ccc6e69a29 LibC: Implement popen() and pclose().
I feel reasonably confident that I might have gotten these right. :^)
2019-06-03 21:17:58 +02:00

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;