aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.guard/guard.ccm
diff options
context:
space:
mode:
Diffstat (limited to 'nihil.guard/guard.ccm')
-rw-r--r--nihil.guard/guard.ccm12
1 files changed, 7 insertions, 5 deletions
diff --git a/nihil.guard/guard.ccm b/nihil.guard/guard.ccm
index c586a20..7b6cf66 100644
--- a/nihil.guard/guard.ccm
+++ b/nihil.guard/guard.ccm
@@ -26,22 +26,24 @@ struct guard final {
* We are being destroyed, so call the callable.
* If the callable throws, std::terminate() will be called.
*/
- ~guard() {
+ ~guard()
+ {
if (m_func)
std::invoke(*m_func);
}
// Release the guard. This turns the destructor into a no-op.
- void release() noexcept {
- m_func.reset();
+ auto release(this guard &self) noexcept -> void
+ {
+ self.m_func.reset();
}
// Not default-constructible, movable or copyable.
guard() = delete;
guard(guard const &) = delete;
guard(guard &&) noexcept = delete;
- guard &operator=(guard const &) = delete;
- guard &operator=(guard &&) noexcept = delete;
+ auto operator=(this guard &, guard const &) -> guard & = delete;
+ auto operator=(this guard &, guard &&) noexcept -> guard & = delete;
private:
// The callable to be invoked when we are destroyed.