1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:47:46 +00:00

AK: Rename ValueRestorer => ScopedValueRollback.

Qt had a pretty good name for this concept, so let's steal it. :^)
This commit is contained in:
Andreas Kling 2019-07-25 15:15:14 +02:00
parent 03b9f6b7f8
commit 9fb2a65716
3 changed files with 8 additions and 8 deletions

26
AK/ScopedValueRollback.h Normal file
View file

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