Given boost::bind or the std:: equivalents, I can make this:
int f(int a, int b)
{
return a + b;
}
auto f_two = boost::bind(f, 1, 1);
So that f_two() will return 2 by effectively calling an intermediate function that calls f(1, 1) via whatever implementation mechanism, perhaps something along the lines of:
double f_two_caller()
{
return f(stored_arg_1, stored_arg_2);
}
However, my use case is that I would want to bind a prefix function so instead I could say:
auto f_print = boost::bind(printf, "Hello, world!\n");
auto f_print_and_two = boost::bind_with_prefix(f, f_print, 1, 1);
So f_print_and_two() effectively executes:
double f_print_and_two_caller()
{
f_print(f_print.stored_arg_1);
return f(stored_arg_1, stored_arg_2);
}
I'm sure there's a proper name for this technique that I could use to look up the solution, but I can't think of it right now...
f()can not be modified and I want to wrap up the final solution as a mixin class or the like.boost::hof::decoratewhich looks as if it would also solve the problem.