aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.guard
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-06-29 17:16:22 +0100
committerLexi Winter <lexi@le-fay.org>2025-06-29 17:16:22 +0100
commit4fa6821e0645ff61a9380cd090abff472205c630 (patch)
treebd95f13b2dc0bd9692681f50c365d2914a520bfe /nihil.guard
parente5180acf5f2dfac788e8c12886095ed1ac66fae5 (diff)
downloadnihil-4fa6821e0645ff61a9380cd090abff472205c630.tar.gz
nihil-4fa6821e0645ff61a9380cd090abff472205c630.tar.bz2
add clang-tidy support
Diffstat (limited to 'nihil.guard')
-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.