#pragma once
#include <functional>
template<class T>
class GuardCls
{
public:
using param_t = typename std::conditional<std::is_reference<T>::value || std::is_pointer<T>::value, T, T&>::type;
using func_t = std::function<void(param_t)>;
GuardCls(param_t param, func_t&& clear) :m_param(param), m_clear(std::move(clear)) {}
GuardCls(param_t param, func_t&& init, func_t&& clear) :m_param(param), m_clear(std::move(clear))
{
init(m_param);
}
~GuardCls() { m_clear(m_param); }
GuardCls() = delete;
GuardCls(const GuardCls&) = delete;
GuardCls& operator=(const GuardCls&) = delete;
GuardCls(const GuardCls&&) = delete;
GuardCls& operator=(const GuardCls&&) = delete;
private:
param_t m_param;
func_t m_clear;
};
#include "GuardCls.hpp"
#include <iostream>
using namespace std;
#define FUNCLOG \
GuardCl