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