#pragma once
#include <functional>

namespace myapp::utils {

class scope_guard final
{
public:
    template<class F>
    scope_guard(F f)
        : deleter_(std::forward<F>(f))
    { }

    ~scope_guard()
    {
        std::invoke(deleter_);
    }

    scope_guard(scope_guard &&) = default;
    scope_guard& operator=(scope_guard &&) = default;

private:
    std::function<void()> deleter_;
};

} /* namespace myapp::utils */
