Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame^] | 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 | static unsigned |
| 19 | func_impl(int arg1, bool arg2, double arg3) |
| 20 | { |
| 21 | using namespace std; |
| 22 | return abs (static_cast<int>((arg2 ? arg1 : 2 * arg1) * arg3)); |
| 23 | } |
| 24 | |
| 25 | int test_main(int, char*[]) |
| 26 | { |
| 27 | using ndnboost::function; |
| 28 | using namespace ndnboost::lambda; |
| 29 | |
| 30 | function <unsigned(bool, double)> f1 = bind(func_impl, 15, _1, _2); |
| 31 | function <unsigned(double)> f2 = ndnboost::lambda::bind(f1, false, _1); |
| 32 | function <unsigned()> f3 = ndnboost::lambda::bind(f2, 4.0); |
| 33 | |
| 34 | f3(); |
| 35 | |
| 36 | return 0; |
| 37 | } |
| 38 | |