So c++17 has std::function
Deduction Guides so given:
int foo();
I can do:
std::function bar(foo);
But I'm stuck on a c++14 compiler. There I have to do something more like: function<int()> bar(foo)
. I was wondering if there was a way to create a std::function
without passing the function pointer and explicitly providing the function signature? So for example make_pair
will deduce the type of it's return from it's arguments. I was wondering if I could write something similar for function
s even using c++14, like:
auto bar = make_function(foo);
Is this doable?
Note: My real case is that foo
is a template function with a lot of arguments I don't want to deduce. So my motivation here is to generate a function
without needing to provide the parameter types.