util/ScopeExit: use std::exchange()
This commit is contained in:
parent
70b451db7b
commit
7a99a7008c
@ -43,9 +43,8 @@ public:
|
|||||||
explicit ScopeExitGuard(F &&f) noexcept:F(std::forward<F>(f)) {}
|
explicit ScopeExitGuard(F &&f) noexcept:F(std::forward<F>(f)) {}
|
||||||
|
|
||||||
ScopeExitGuard(ScopeExitGuard &&src) noexcept
|
ScopeExitGuard(ScopeExitGuard &&src) noexcept
|
||||||
:F(std::move(src)), enabled(src.enabled) {
|
:F(std::move(src)),
|
||||||
src.enabled = false;
|
enabled(std::exchange(src.enabled, false)) {}
|
||||||
}
|
|
||||||
|
|
||||||
/* destructors are "noexcept" by default; this explicit
|
/* destructors are "noexcept" by default; this explicit
|
||||||
"noexcept" declaration allows the destructor to throw if
|
"noexcept" declaration allows the destructor to throw if
|
||||||
|
Loading…
Reference in New Issue
Block a user