/**
 * \file
 */

#ifndef ESTD_SCOPEGUARD_HPP_
#define ESTD_SCOPEGUARD_HPP_

template<typename Function>
class ScopeGuard
{
public:

	/**
	 * \brief ScopeGuard's constructor
	 *
	 * \param [in] function is a rvalue reference to function executed on scope exit
	 */

	constexpr explicit ScopeGuard(Function&& function) noexcept :
			function_{std::move(function)},
			released_{}
	{

	}

	/**
	 * \brief ScopeGuard's move constructor
	 *
	 * \param [in] other is a rvalue reference to ScopeGuard used as source of move
	 */

	ScopeGuard(ScopeGuard&& other) noexcept :
			function_(std::move(other.function_)),
			released_{other.released_}
	{
		other.release();
	}
};

#endif	// ESTD_SCOPEGUARD_HPP_
