xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
scope_exit.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
11
namespace
xtd
{
65
struct
scope_exit
{};
66
68
template
<
typename
function_t>
69
requires
xtd::action_callable<function_t>
&& std::is_nothrow_invocable_v<function_t&>
70
struct
__xtd_scope_exit_object__ {
71
__xtd_scope_exit_object__(function_t&& f) : function(std::forward<function_t>(
f
)) {}
72
~__xtd_scope_exit_object__() noexcept { function(); }
73
function_t
function
;
74
};
75
76
template
<
typename
function_t>
77
requires
xtd::action_callable<function_t> && std::is_nothrow_invocable_v<function_t&>
78
auto
operator +(
scope_exit
, function_t&& function) {
79
return
__xtd_scope_exit_object__<function_t> {std::forward<function_t>(function)};
80
}
82
}
83
137
#define scope_exit_ \
138
[[maybe_unused]] auto __ = xtd::scope_exit {} + [&]()
action_callable.hpp
Contains xtd::action_callable concept.
xtd::action_callable
Definition
action_callable.hpp:11
xtd::console_key::f
@ f
The F key.
Definition
console_key.hpp:98
xtd::forms::keys::function
@ function
The FUNCTION modifier key.
Definition
keys.hpp:480
xtd
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition
abstract_object.hpp:8
xtd::scope_exit
Nowadays, every C++ developer is familiar with the Resource Acquisition Is Initialization (RAII) tech...
Definition
scope_exit.hpp:65
unused.hpp
Contains __ and unused_ keywords.
Generated on
for xtd by
Gammasoft
. All rights reserved.