The following code example is taken from the book
The C++ Standard Library - A Tutorial and Reference, 2nd Edition
by Nicolai M. Josuttis, Addison Wesley Longman, 2012
Copyright © 2012 by Pearson Education, Inc. and Nicolai M. Josuttis
#include <functional>
#include <iostream>
int main()
{
auto plus10 = std::bind(std::plus<int>(),
std::placeholders::_1,
10);
std::cout << "+10: " << plus10(7) << std::endl;
auto plus10times2 = std::bind(std::multiplies<int>(),
std::bind(std::plus<int>(),
std::placeholders::_1,
10),
2);
std::cout << "+10 *2: " << plus10times2(7) << std::endl;
auto pow3 = std::bind(std::multiplies<int>(),
std::bind(std::multiplies<int>(),
std::placeholders::_1,
std::placeholders::_1),
std::placeholders::_1);
std::cout << "x*x*x: " << pow3(7) << std::endl;
auto inversDivide = std::bind(std::divides<double>(),
std::placeholders::_2,
std::placeholders::_1);
std::cout << "invdiv: " << inversDivide(49,7) << std::endl;
}