-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Copyright (C) 2022 Linux Studio Plugins Project <https://lsp-plug.in/> | ||
* (C) 2022 Vladimir Sadovnikov <[email protected]> | ||
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/> | ||
* (C) 2024 Vladimir Sadovnikov <[email protected]> | ||
* | ||
* This file is part of lsp-common-lib | ||
* Created on: 29 июн. 2022 г. | ||
|
@@ -23,6 +23,7 @@ | |
#define LSP_PLUG_IN_COMMON_FINALLY_H_ | ||
|
||
#include <lsp-plug.in/common/version.h> | ||
#include <lsp-plug.in/common/variadic.h> | ||
|
||
namespace lsp | ||
{ | ||
|
@@ -33,23 +34,24 @@ namespace lsp | |
T sActor; | ||
|
||
public: | ||
inline FinallyExecutor(T && actor): sActor(actor) {} | ||
inline FinallyExecutor(T && actor): sActor(lsp::move(actor)) {} | ||
inline FinallyExecutor(T & actor) : sActor(actor) {} | ||
~FinallyExecutor() { sActor(); } | ||
}; | ||
|
||
struct FinallyExecutorInit | ||
{ | ||
template <class T> | ||
inline FinallyExecutor<T> operator + (T & actor) | ||
{ | ||
return FinallyExecutor<T>(actor); | ||
} | ||
inline FinallyExecutor<T> operator + (T & actor) | ||
{ | ||
return FinallyExecutor<T>(actor); | ||
} | ||
|
||
template <class T> | ||
inline FinallyExecutor<T> operator + (T && actor) | ||
{ | ||
return FinallyExecutor<T>(actor); | ||
} | ||
inline FinallyExecutor<T> operator + (T && actor) | ||
{ | ||
return FinallyExecutor<T>(lsp::move(actor)); | ||
} | ||
}; | ||
|
||
#define lsp_impl_finally2(id, prefix) prefix ## id ## __ | ||
|
@@ -59,14 +61,6 @@ namespace lsp | |
|
||
#define lsp_finally lsp_impl_finally0(__COUNTER__) | ||
|
||
template <class T> | ||
inline T * release_ptr(T * & value) | ||
{ | ||
T *res = value; | ||
value = nullptr; | ||
return res; | ||
} | ||
|
||
} /* namespace lsp */ | ||
|
||
#endif /* LSP_PLUG_IN_COMMON_FINALLY_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters