From 1e7900d383a57231e975a1e5443f5ffb8ac58c4b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 12 Nov 2011 17:59:01 +0100 Subject: [PATCH] Lightweight class for running code at scope exit --- src/common/at_scope_exit.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/common/at_scope_exit.h diff --git a/src/common/at_scope_exit.h b/src/common/at_scope_exit.h new file mode 100644 index 000000000..7c622da01 --- /dev/null +++ b/src/common/at_scope_exit.h @@ -0,0 +1,27 @@ +/* + mkvmerge -- utility for splicing together matroska files + from component media subtypes + + Distributed under the GPL + see the file COPYING for details + or visit http://www.gnu.org/copyleft/gpl.html + + run code at scope exit + + Written by Moritz Bunkus . +*/ + +#ifndef MTX_COMMON_AT_SCOPE_EXIT_H +#define MTX_COMMON_AT_SCOPE_EXIT_H + +class at_scope_exit_c { +private: + std::function m_code; +public: + at_scope_exit_c(const std::function &code) : m_code(code) {} + ~at_scope_exit_c() { + m_code(); + } +}; + +#endif // MTX_COMMON_AT_SCOPE_EXIT_H