I would like to do the following. Say I have this:
void f(const char* c) {
// Do stuff with c
}
void g(const char* c, int x, int y) {
// Do other stuff
}
What I'd like to do is to create a function from g that takes a const char* c. That is:
int a = 5;
int b = 9;
expression(g, a, b)("Hi!");
Preferably, expression(g)
can be stored in a variable as well. I'm not sure how to declare this variable either.
I have tried using boost::bind; however boost::bind returns a boost::function, and I would like a normal C++ function pointer. Additionally, I also saw this thread: demote boost::function to a plain function pointer And neither of the top two solution will work. My function f is constrained to take one parameter (no void* user_data pointer). The reason I need this is that I have a third function, h, that takes in a function of one argument, namely a const char* and does things with it. I'd like to be able to pass in a form of g to h.
h(f) // Valid
h(expression(g, a, b)) // Would like for this to be valid, too
I'm not sure if this is possible, but if it is, do tell :).