I am trying to write a wrapper make_function, which like std::make_pair can create a std::function object out of suitable callable obj
In general you cannot solve it without the severe restriction that whatever you pass to make_function is only callable with exactly one signature.
What are you going to do with something like:
struct Generic
{
void operator()() { /* ... */ }
void operator()() const { /* ... */ }
template
T operator()(T&& t, Ts&&...) { /* ... */ }
template
T operator()(T&& t, Ts&&...) const { /* ... */ }
};
C++14 generic lambdas will have the same issue.
The signature in std::function is based on how you plan to call it and not on how you construct/assign it.
You cannot solve it for std::bind either, as that has indefinite arity:
void foo() { std::cout << "foo()" << std::endl; }
//...
auto f = std::bind(foo);
f(); // writes "foo()"
f(1); // writes "foo()"
f(1, 2, 3, 4, 5, 6); // writes "foo()"