/*
 * Copyright 2015 - 2025 gary@drinkingtea.net
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#pragma once

namespace ox {

template<typename T>
class Defer {
	private:
		T m_deferredFunc;

	public:
		constexpr Defer(T deferredFunc) noexcept: m_deferredFunc(deferredFunc) {
		}

		Defer(const Defer&) = delete;

		constexpr ~Defer() {
			m_deferredFunc();
		}

		Defer &operator=(const Defer&) = delete;

};

}

#define OX_DEFER ox::Defer const OX_CONCAT(oxDefer_, __LINE__) =
