mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-15 00:10:35 +03:00
AK: Add a TemporaryChange helper class.
This commit is contained in:
parent
8cc6e304ca
commit
781f216676
Notes:
sideshowbarker
2024-07-19 15:51:01 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/781f216676a
18
AK/TemporaryChange.h
Normal file
18
AK/TemporaryChange.h
Normal 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;
|
Loading…
Reference in New Issue
Block a user