mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-02-17 17:24:54 +00:00
Lightweight class for running code at scope exit
This commit is contained in:
parent
99dfe10ad6
commit
1e7900d383
27
src/common/at_scope_exit.h
Normal file
27
src/common/at_scope_exit.h
Normal file
@ -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 <moritz@bunkus.org>.
|
||||
*/
|
||||
|
||||
#ifndef MTX_COMMON_AT_SCOPE_EXIT_H
|
||||
#define MTX_COMMON_AT_SCOPE_EXIT_H
|
||||
|
||||
class at_scope_exit_c {
|
||||
private:
|
||||
std::function<void()> m_code;
|
||||
public:
|
||||
at_scope_exit_c(const std::function<void()> &code) : m_code(code) {}
|
||||
~at_scope_exit_c() {
|
||||
m_code();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MTX_COMMON_AT_SCOPE_EXIT_H
|
Loading…
Reference in New Issue
Block a user