diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-06-03 19:52:31 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-03 21:17:58 +0200 |
commit | ccc6e69a294edacf7bec77cb2c2640ada7fe1f77 (patch) | |
tree | 49b05e95d9003b7f1f4f66620c3e051a27648d91 /AK | |
parent | e92fe52031be8d502cf0e6aa08bd2037a11096e9 (diff) | |
download | serenity-ccc6e69a294edacf7bec77cb2c2640ada7fe1f77.zip |
LibC: Implement popen() and pclose().
I feel reasonably confident that I might have gotten these right. :^)
Diffstat (limited to 'AK')
-rw-r--r-- | AK/ValueRestorer.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/AK/ValueRestorer.h b/AK/ValueRestorer.h new file mode 100644 index 0000000000..99fa43e187 --- /dev/null +++ b/AK/ValueRestorer.h @@ -0,0 +1,26 @@ +#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; |