xtd 1.0.0
Loading...
Searching...
No Matches
finally.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "action_callable.hpp"
6#include "unused.hpp"
7#include <exception>
8#include <utility>
9
11namespace xtd {
65 struct finally {};
66
68 template<typename function_t>
69 struct __xtd_finally_object__ {
70 __xtd_finally_object__(function_t&& f) : function(std::forward<function_t>(f)) {}
71 ~__xtd_finally_object__() noexcept { function(); }
72 function_t function;
73 };
74
75 template<typename function_t>
76 requires xtd::action_callable<function_t> && std::is_nothrow_invocable_v<function_t&>
77 auto operator +(finally, function_t&& function) {
78 return __xtd_finally_object__<function_t> {std::forward<function_t>(function)};
79 }
81}
82
125#define finally_ \
126 [[maybe_unused]] auto __ = xtd::finally {} + [&]() noexcept
Contains xtd::action_callable concept.
@ 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:65
Contains __ and unused_ keywords.