I have a function foo:
void foo(int n) {}
and I want to have a pointer that points to the function, but calls it with a specified parameter. So basically, something like this:
auto bar = //init
bar(); //calls foo(2)
I have a function foo:
void foo(int n) {}
and I want to have a pointer that points to the function, but calls it with a specified parameter. So basically, something like this:
auto bar = //init
bar(); //calls foo(2)
You can use std::bind:
auto bar = std::bind(foo, 2);
then you can call it like so:
bar();
bar would have a return type of void and no arguments. You can use std::function as a type to the vector: std::vector<std::function<void(void)>> v;