retdec
|
Macro for performing actions when the current block exits. More...
Go to the source code of this file.
Classes | |
class | retdec::utils::ScopeExitGuard< Function > |
struct | retdec::utils::ScopeExitGuardHelper |
Namespaces | |
retdec | |
retdec::utils | |
Macros | |
#define | SCOPE_EXIT_CONCATENATE_IMPL(s1, s2) s1##s2 |
#define | SCOPE_EXIT_CONCATENATE(s1, s2) SCOPE_EXIT_CONCATENATE_IMPL(s1, s2) |
#define | SCOPE_EXIT_ANONYMOUS_VARIABLE SCOPE_EXIT_CONCATENATE(SCOPE_EXIT_ANONYMOUS_VARIABLE_, __LINE__) |
#define | SCOPE_EXIT |
Macro for performing actions when the current block exits. More... | |
Functions | |
template<typename Function > | |
auto | retdec::utils::operator+ (ScopeExitGuardHelper, Function &&f) |
Macro for performing actions when the current block exits.
The code is based on the following presentation: CppCon 2015: Andrei Alexandrescu: "Declarative Control Flow" (https://www.youtube.com/watch?v=WjTrfoiB0MQ).
#define SCOPE_EXIT |
Macro for performing actions when the current block exits.
Usage:
Important: Do not forget the trailing semicolon!
The above statements are executed when the current block exits, either normally or via an exception. All variables from outer blocks are automatically captured by reference.
This macro is useful for performing automatic cleanup actions, mainly when there is no RAII support.
#define SCOPE_EXIT_ANONYMOUS_VARIABLE SCOPE_EXIT_CONCATENATE(SCOPE_EXIT_ANONYMOUS_VARIABLE_, __LINE__) |
#define SCOPE_EXIT_CONCATENATE | ( | s1, | |
s2 | |||
) | SCOPE_EXIT_CONCATENATE_IMPL(s1, s2) |
#define SCOPE_EXIT_CONCATENATE_IMPL | ( | s1, | |
s2 | |||
) | s1##s2 |