blob: 86281faa0882df5a30301d6415cbd93d9c62fde5 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// 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
18static unsigned
19func_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
25int 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