Merge tag 'v0.23.13'

release v0.23.13
This commit is contained in:
Max Kellermann
2023-05-22 19:50:56 +02:00
13 changed files with 75 additions and 61 deletions

View File

@@ -14,14 +14,17 @@ class ScopeExitGuard : F {
bool enabled = true;
public:
explicit ScopeExitGuard(F &&f):F(std::forward<F>(f)) {}
explicit ScopeExitGuard(F &&f) noexcept:F(std::forward<F>(f)) {}
ScopeExitGuard(ScopeExitGuard &&src)
:F(std::move(src)), enabled(src.enabled) {
src.enabled = false;
}
ScopeExitGuard(ScopeExitGuard &&src) noexcept
:F(std::move(src)),
enabled(std::exchange(src.enabled, false)) {}
~ScopeExitGuard() {
/* destructors are "noexcept" by default; this explicit
"noexcept" declaration allows the destructor to throw if
the function can throw; without this, a throwing function
would std::terminate() */
~ScopeExitGuard() noexcept(noexcept(std::declval<F>()())) {
if (enabled)
F::operator()();
}
@@ -38,7 +41,7 @@ struct ScopeExitTag {
parantheses at the end of the expression AtScopeExit()
call */
template<typename F>
ScopeExitGuard<F> operator+(F &&f) {
ScopeExitGuard<F> operator+(F &&f) noexcept {
return ScopeExitGuard<F>(std::forward<F>(f));
}
};