1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <functional>
void multiply(int a, int b) {
std::cout << a * b << std::endl;
}
int main() {
// Bind the first argument to 2
std::function<void(int)> multiplyByTwo = std::bind(multiply, 2, std::placeholders::_1);
multiplyByTwo(5); // Outputs: 10
return 0;
}
Back to std_bind