#ifndef FUNCTIONUTILS_H_
#define FUNCTIONUTILS_H_

#include <functional>

using std::function;

template<typename T>
struct memfun_type
{
	using type = void;
};

template<typename Ret, typename Class, typename... Args>
struct memfun_type<Ret(Class::*)(Args...) const>
{
	using type = std::function<Ret(Args...)>;
};

template<typename F>
typename memfun_type<decltype(&F::operator())>::type
function_from_lambda(F const& func)
{
	return func;
}

template <typename returnType, typename... ArgTypes>
function< returnType(ArgTypes...) > stdfunction_from_functionptr(returnType(*f) (ArgTypes...))
{
	function< returnType(ArgTypes...) > func = f;
	return func;
}

#endif