xtd 0.2.0
Loading...
Searching...
No Matches
scope_exit.h
Go to the documentation of this file.
1
4#pragma once
5#include <utility>
6
8namespace xtd {
45 struct scope_exit {
46 };
47
49 template<typename function_t>
50 struct __xtd_scope_exit_object__ {
51 ~__xtd_scope_exit_object__() { function(); }
52 function_t function;
53 };
54
55 template<typename function_t>
56 auto operator +(scope_exit, function_t&& function) {
57 return __xtd_scope_exit_object__<function_t>{std::forward<function_t>(function)};
58 }
60}
61
63#define __xtd_scope_exit_cat__(name, line) name##line
64#define __xtd_scope_exit_id__(name, line) __xtd_scope_exit_cat__(name, line)
66
103#define scope_exit_ [[maybe_unused]] auto __xtd_scope_exit_id__(__xtd__scope_exit__, __LINE__) = xtd::scope_exit {} + [&]
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Nowadays, every C++ developer is familiar with the Resource Acquisition Is Initialization (RAII) tech...
Definition scope_exit.h:45