/*
Consider this following small example program.
*/
#include <functional>
#include <iostream>
using namespace std::placeholders;
/*
We write a subroutine that outputs the multiple of its arguments, a and b.
*/
void multiple(int a, int b, const std::string & who) {
std::cout << who << ":\t" << a << "×" << b << "=" << a*b << std::endl;
}
int main() {
/*
We then call it from main.
*/
multiple(2,3,"direct");
/*
Next, we want to use bind to bind some arguments and call it. Unsurprisingly, the output is the same.
*/
std::bind(multiple,2,3,"bind")();
/*
We can also store this bound function and call it:
*/
auto bound(std::bind(multiple,2,3,"bound"));
bound();
/*
Things get wicked, when we want to predefine only one parameter, though :(
*/
//std::bind(multiple,2,_1,"bindp")(3); // you wish!