AK: Add a TemporaryChange helper class.

This commit is contained in:
Andreas Kling 2019-02-06 16:01:59 +01:00
parent 8cc6e304ca
commit 781f216676
Notes: sideshowbarker 2024-07-19 15:51:01 +09:00

18
AK/TemporaryChange.h Normal file
View File

@ -0,0 +1,18 @@
#pragma once
namespace AK {
template<typename T>
class TemporaryChange {
public:
TemporaryChange(T& variable, T value) : m_variable(variable), m_old_value(variable) { m_variable = value; }
~TemporaryChange() { m_variable = m_old_value; }
private:
T& m_variable;
T m_old_value;
};
}
using AK::TemporaryChange;