CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
scope_guard.h
1
3#ifndef _aspose_system_scope_guard_h_
4#define _aspose_system_scope_guard_h_
5
6namespace System
7{
8
12template <typename F>
14{
17 ScopeGuard(F f) : f(f)
18 {}
19#if defined(_MSC_VER)
20#pragma warning(push)
21// Warning C4722: destructor never returns, potential memory leak.
22#pragma warning(disable : 4722)
23#endif
25 ~ScopeGuard() noexcept(false) { f(); }
26#if defined(_MSC_VER)
27#pragma warning(pop)
28#endif
29private:
31 F f;
32};
33
34// auto guard = MakeScopeGuard([&](){
35// .....
36// });
41template <typename F>
43{
44 return ScopeGuard<F>(f);
45};
46
47} // namespace System
48#endif // _aspose_system_scope_guard_h_
Definition: db_command.h:9
ScopeGuard< F > MakeScopeGuard(F f)
A factory function that creates instances of ScopedGuard class.
Definition: scope_guard.h:42
The service class that provides services for running a particular function object when an instance of...
Definition: scope_guard.h:14
~ScopeGuard() noexcept(false)
Invokes the function object passed to the constructor.
Definition: scope_guard.h:25
ScopeGuard(F f)
Constructs an instance that is set up to invoke the specified function object.
Definition: scope_guard.h:17