Skip to content

Commit

Permalink
Merge pull request #487 from Ghabry/scopeguard
Browse files Browse the repository at this point in the history
ScopeGuard: Allow move assignment
  • Loading branch information
fdelapena authored Nov 28, 2024
2 parents 4d15bee + db2d122 commit f166025
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lcf/scope_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ class ScopeGuard {
ScopeGuard(const ScopeGuard&) = delete;
ScopeGuard& operator=(const ScopeGuard&) = delete;

ScopeGuard(ScopeGuard&& o)
ScopeGuard(ScopeGuard&& o) noexcept
: _f(std::move(o._f)), _active(true) { o._active = false; }
ScopeGuard& operator=(ScopeGuard&&) = delete;
ScopeGuard& operator=(ScopeGuard&& o) noexcept {
_f = std::move(o._f);
o._active = false;
return *this;
};

~ScopeGuard() { Fire(); }

Expand Down

0 comments on commit f166025

Please sign in to comment.