FreeRDP
scoped_guard.hpp
1
21
#pragma once
22
23
#include <functional>
24
25
class
ScopeGuard
26
{
27
public
:
28
template
<
class
Callable>
explicit
ScopeGuard
(Callable&& cleanupFunction)
29
try
: f(std::forward<Callable>(cleanupFunction))
30
{
31
}
32
catch
(...)
33
{
34
cleanupFunction();
35
throw
;
36
}
37
38
~
ScopeGuard
()
39
{
40
if
(f)
41
f();
42
}
43
44
void
dismiss() noexcept
45
{
46
f =
nullptr
;
47
}
48
49
ScopeGuard
(
const
ScopeGuard
&) =
delete
;
50
ScopeGuard
(
ScopeGuard
&& other) noexcept =
delete
;
51
ScopeGuard
& operator=(
const
ScopeGuard
&) =
delete
;
52
ScopeGuard
& operator=(
const
ScopeGuard
&&) =
delete
;
53
54
private
:
55
std::function<void()> f;
56
};
ScopeGuard
Definition:
scoped_guard.hpp:26
client
SDL
common
scoped_guard.hpp
Generated by
1.9.1