#include <iostream>
#include <type_traits>

using namespace std;

int f()
{
	cout << "f" << endl;
	return 0;
}

struct F {
	int f()
	{
		cout << "F::f" << endl;
		return 0;
	}	
};

template <typename Function>
typename std::result_of<typename std::remove_reference<Function>::type>::type
call_f(Function&& f)
{
	return f();	
}

template <typename Function, class Class>
typename std::result_of<Function>::type
call_mf(Function&& f, Class* instance)
{
	return instance->*f();    
}

int main()
{
	call_f(f);
	
	F instance;
	
	call_fm(&F::f, &instance);
	
	return 0;
}
