Merge tag 'v0.23.13'
release v0.23.13
This commit is contained in:
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user