|
Last change
on this file since 33 was
29,
checked in by landauf, 17 years ago
|
|
updated boost from 1_33_1 to 1_34_1
|
|
File size:
932 bytes
|
| Line | |
|---|
| 1 | // Boost.Function library |
|---|
| 2 | |
|---|
| 3 | // Copyright Douglas Gregor 2002-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 <cstdlib> |
|---|
| 12 | |
|---|
| 13 | #include <boost/test/minimal.hpp> |
|---|
| 14 | #include <boost/lambda/lambda.hpp> |
|---|
| 15 | #include <boost/lambda/bind.hpp> |
|---|
| 16 | #include <boost/function.hpp> |
|---|
| 17 | |
|---|
| 18 | using namespace std; |
|---|
| 19 | using namespace boost; |
|---|
| 20 | using namespace boost::lambda; |
|---|
| 21 | |
|---|
| 22 | static unsigned |
|---|
| 23 | func_impl(int arg1, bool arg2, double arg3) |
|---|
| 24 | { |
|---|
| 25 | return abs (static_cast<int>((arg2 ? arg1 : 2 * arg1) * arg3)); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | int test_main(int, char*[]) |
|---|
| 29 | { |
|---|
| 30 | function <unsigned(bool, double)> f1 = bind(func_impl, 15, _1, _2); |
|---|
| 31 | function <unsigned(double)> f2 = bind(f1, false, _1); |
|---|
| 32 | function <unsigned()> f3 = bind(f2, 4.0); |
|---|
| 33 | |
|---|
| 34 | f3(); |
|---|
| 35 | |
|---|
| 36 | return 0; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.