Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/function/test/lambda_test.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

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
18using namespace std;
19using namespace boost;
20using namespace boost::lambda;
21
22static unsigned
23func_impl(int arg1, bool arg2, double arg3)
24{
25  return abs (static_cast<int>((arg2 ? arg1 : 2 * arg1) * arg3));
26}
27
28int 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.