// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_CORE_CALLONEXIT_HPP #define NAZARA_CORE_CALLONEXIT_HPP #include #include namespace Nz { template class CallOnExit { public: CallOnExit() = default; CallOnExit(F&& functor); CallOnExit(const CallOnExit&) = delete; CallOnExit(CallOnExit&&) noexcept = delete; ~CallOnExit(); void CallAndReset(); void Reset(); CallOnExit& operator=(const CallOnExit&) = delete; CallOnExit& operator=(CallOnExit&&) noexcept = default; private: std::optional m_functor; }; template CallOnExit(F) -> CallOnExit; } #include #endif // NAZARA_CORE_CALLONEXIT_HPP