[ox/std] Cleanup Defer

This commit is contained in:
Gary Talent 2024-09-13 23:51:58 -05:00
parent 5834b9c98d
commit 76760dafb6

View File

@ -8,8 +8,6 @@
#pragma once
#include "error.hpp"
namespace ox {
template<typename T>
@ -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__) =