xtd 1.0.0
Loading...
Searching...
No Matches
finally.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "unused.hpp"
6#include <exception>
7#include <utility>
8
10namespace xtd {
64 struct finally {};
65
67 template<typename function_t>
68 struct __xtd_finally_object__ {
69 __xtd_finally_object__(function_t&& f) : function(std::forward<function_t>(f)) {}
70 ~__xtd_finally_object__() { function(); }
71 function_t function;
72 };
73
74 template<typename function_t>
75 auto operator +(finally, function_t&& function) {
76 return __xtd_finally_object__<function_t> {std::forward<function_t>(function)};
77 }
79}
80
123#define finally_ \
124 [[maybe_unused]] auto __ = xtd::finally {} + [&]
@ f
The F key.
Definition console_key.hpp:98
@ function
The FUNCTION modifier key.
Definition keys.hpp:480
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Nowadays, every C++ developer is familiar with the Resource Acquisition Is Initialization (RAII) tech...
Definition finally.hpp:64
Contains __ and unused_ keywords.