Line | |
---|
1 | // 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 | |
---|
13 | struct int_div { |
---|
14 | float operator()(int x, int y) const { return ((float)x)/y; }; |
---|
15 | }; |
---|
16 | |
---|
17 | int |
---|
18 | main() |
---|
19 | { |
---|
20 | boost::function<float (int, int)> f; |
---|
21 | f = int_div(); |
---|
22 | |
---|
23 | std::cout << f(5, 3) << std::endl; // 1.66667 |
---|
24 | |
---|
25 | return 0; |
---|
26 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.