I would suggest you first cast your pointer, and then wrap it into a std::function:
template<Signature>
std::function<Signature> to_function(FARPROC f)
{
return std::function<Signature>(reinterpret_cast<Signature*>(f));
}
IMHO it would be a good idea to name such a function cast_to_function
. Its name should sound dangerous.