diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-11-21 14:31:45 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-11-21 14:31:45 +0800 |
| commit | 3cda35dbcbbe1e3854b880169c0efa0fc7a79264 (patch) | |
| tree | 4fa9cc195146b0e28bb9cb186cdbd011166e6024 /include/cru/base/Guard.h | |
| parent | 2369893a6e07d1837e5df29bdde210decc951557 (diff) | |
| download | cru-3cda35dbcbbe1e3854b880169c0efa0fc7a79264.tar.gz cru-3cda35dbcbbe1e3854b880169c0efa0fc7a79264.tar.bz2 cru-3cda35dbcbbe1e3854b880169c0efa0fc7a79264.zip | |
Use AutoDestruct to impl EventHandlerRevokerGuard.
Diffstat (limited to 'include/cru/base/Guard.h')
| -rw-r--r-- | include/cru/base/Guard.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/cru/base/Guard.h b/include/cru/base/Guard.h index a23e2574..ae120f5a 100644 --- a/include/cru/base/Guard.h +++ b/include/cru/base/Guard.h @@ -43,7 +43,7 @@ inline AutoFreePtr<T> MakeAutoFree(T* ptr) { return AutoFreePtr<T>(ptr); } -template <typename T, void (*DestructFunc)(T value) noexcept> +template <typename T, typename Destructor> class AutoDestruct { public: AutoDestruct() : value_(std::nullopt), auto_destruct_(false) {} @@ -110,7 +110,7 @@ class AutoDestruct { private: void DoDestruct() { if (auto_destruct_ && value_) { - DestructFunc(*value_); + Destructor{}(*value_); } } |
