blob: 8dfc68a9710895558e38859fe309b074b4e68127 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// Boost.Function library examples
2
3// Copyright Douglas Gregor 2001-2003. Use, modification and
4// distribution is subject to the Boost Software License, Version
5// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7
8// For more information, see http://www.boost.org
9
10#include <iostream>
11#include <boost/function.hpp>
12#include <functional>
13
14struct X {
15 X(int val) : value(val) {}
16
17 int foo(int x) { return x * value; }
18
19 int value;
20};
21
22
23int
24main()
25{
26 ndnboost::function<int (int)> f;
27 X x(7);
28 f = std::bind1st(std::mem_fun(&X::foo), &x);
29
30 std::cout << f(5) << std::endl; // Call x.foo(5)
31 return 0;
32}