1// bll_and_function.cpp - The Boost Lambda Library -----------------------
2//
3// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
4// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
5//
6// Distributed under the Boost Software License, Version 1.0. (See
7// accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9//
10// For more information, see www.boost.org
11
12// test using BLL and boost::function
13
14#include <boost/test/minimal.hpp> // see "Header Implementation Option"
15
16#include "boost/lambda/lambda.hpp"
17#include "boost/lambda/bind.hpp"
18#include "boost/lambda/algorithm.hpp"
19
20#include <vector>
21#include <map>
22#include <set>
23#include <string>
24
25#include <iostream>
26
27
28
29void test_foreach() {
30 using namespace boost::lambda;
31
32 int a[10][20];
33 int sum = 0;
34
35 std::for_each(a, a + 10,
36 bind(ll::for_each(), _1, _1 + 20,
37 protect((_1 = var(sum), ++var(sum)))));
38
39 sum = 0;
40 std::for_each(a, a + 10,
41 bind(ll::for_each(), _1, _1 + 20,
42 protect((sum += _1))));
43
44 BOOST_CHECK(sum == (199 + 1)/ 2 * 199);
45}
46
47// More tests needed (for all algorithms)
48
49int test_main(int, char *[]) {
50
51 test_foreach();
52
53 return 0;
54}
55
56
57
58
59
60
61