Let I have a function
void f1(type_a a, type_b b, type_c c)
I want to convert it to
void f2(type_a a, type_b b)
where instead of c will be passed my object.
How can I do this usind boost:bind?
Let I have a function
void f1(type_a a, type_b b, type_c c)
I want to convert it to
void f2(type_a a, type_b b)
where instead of c will be passed my object.
How can I do this usind boost:bind?
Something like this I think
boost::bind(&f1, _1, _2, c_default_value);
C++ is not a functional language, so you can't make a true partial application of a function. What you can do is the following:
#include <boost/bind.hpp>
void f1(int a, double b, char c)
{}
int main()
{
auto binder = boost::bind(&f1, _1, _2, 'c');
binder(1, 2.0);
}
Note however, that while you can pass binder
to any context where a callable is expected, it is not convertible to a pointer-to-function.