xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
scope_success.hpp
Go to the documentation of this file.
1
4
#pragma once
5
#include "
unused.hpp
"
6
#include <exception>
7
#include <utility>
8
10
namespace
xtd
{
64
struct
scope_success
{ };
65
67
template
<
typename
function_t>
68
struct
__xtd_scope_success_object__ {
69
__xtd_scope_success_object__(function_t&& f) : function(std::forward<function_t>(
f
)) {}
70
~__xtd_scope_success_object__() noexcept {
if
(std::uncaught_exceptions() == exceptions_on_enter) function();}
71
int
exceptions_on_enter = std::uncaught_exceptions();
72
function_t
function
;
73
};
74
75
template
<
typename
function_t>
76
auto
operator+
(
scope_success
, function_t&& function) {
77
return
__xtd_scope_success_object__<function_t> {std::forward<function_t>(function)};
78
}
80
}
81
135
#define scope_success_ \
136
[[maybe_unused]] auto __ = xtd::scope_success{} + [&]
xtd::expressions::operator+
constexpr auto operator+(left_t left, right_t right)
Add the specified left and right operands.
Definition
add_expression.hpp:121
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_success
Nowadays, every C++ developer is familiar with the Resource Acquisition Is Initialization (RAII) tech...
Definition
scope_success.hpp:64
unused.hpp
Contains __ and unused_ keywords.
Generated on
for xtd by
Gammasoft
. All rights reserved.