One simple example explaining how to use std::bindit is as follows:
Suppose we have a function of 3 arguments: f3 (x, y, z). We want to be a function of two arguments, which is defined as: f2(x,y) = f3(x,5,y). In C ++, we can easily do this with std::bind:
auto f2 = std::bind(f3, _1, 5, _2);
This example is clear to me: it std::bindtakes a function as its first argument, and then takes another n arguments, where n is the number of arguments to the function, which is taken as the first argument to std::bind.
However, I found another use of bind:
void foo( int &x )
{
++x;
}
int main()
{
int i = 0;
std::bind( foo, i ) ();
std::cout << i << std::endl;
}
, foo , std::bind i. (foo, i)? std::bind? , auto f = std::bind(foo, i)?