From 76760dafb670cba2f0089755836d006a6a6ad612 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 13 Sep 2024 23:51:58 -0500 Subject: [PATCH] [ox/std] Cleanup Defer --- deps/ox/src/ox/std/defer.hpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/deps/ox/src/ox/std/defer.hpp b/deps/ox/src/ox/std/defer.hpp index 593cc57a..390ffebb 100644 --- a/deps/ox/src/ox/std/defer.hpp +++ b/deps/ox/src/ox/std/defer.hpp @@ -8,8 +8,6 @@ #pragma once -#include "error.hpp" - namespace ox { template @@ -18,13 +16,12 @@ class Defer { T m_deferredFunc; public: - Defer(T deferredFunc) { - m_deferredFunc = deferredFunc; + constexpr Defer(T deferredFunc) noexcept: m_deferredFunc(deferredFunc) { } Defer(const Defer&) = delete; - ~Defer() { + constexpr ~Defer() { m_deferredFunc(); } @@ -34,4 +31,4 @@ class Defer { } -#define oxDefer ox::Defer oxConcat(oxDefer_, __LINE__) = [&] +#define oxDefer ox::Defer const oxConcat(oxDefer_, __LINE__) =