Skip to content

Commit

Permalink
ScopeGuard: Allow move assignment
Browse files Browse the repository at this point in the history
Required to make the callback Api usable
  • Loading branch information
Ghabry committed Nov 22, 2024
1 parent 4d15bee commit db2d122
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 db2d122

Please sign in to comment.