util/ScopeExit: use std::exchange()

This commit is contained in:
Max Kellermann 2023-05-22 14:44:32 +02:00
parent 70b451db7b
commit 7a99a7008c

View File

@ -43,9 +43,8 @@ public:
explicit ScopeExitGuard(F &&f) noexcept:F(std::forward<F>(f)) {}
ScopeExitGuard(ScopeExitGuard &&src) noexcept
:F(std::move(src)), enabled(src.enabled) {
src.enabled = false;
}
:F(std::move(src)),
enabled(std::exchange(src.enabled, false)) {}
/* destructors are "noexcept" by default; this explicit
"noexcept" declaration allows the destructor to throw if