1/*=============================================================================
2 Copyright (c) 2005-2007 Dan Marsden
3 Copyright (c) 2005-2007 Joel de Guzman
4 Copyright (c) 2014-2015 John Fletcher
5
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8==============================================================================*/
9
10#include <boost/phoenix.hpp>
11#include <boost/phoenix/core.hpp>
12#include <boost/phoenix/stl/algorithm/iteration.hpp>
13#include <boost/detail/lightweight_test.hpp>
14
15#include <functional>
16#include <vector>
17#include <string>
18#include <sstream>
19
20namespace
21{
22
23 void for_each_test()
24 {
25 return;
26 using boost::phoenix::for_each;
27 using boost::phoenix::lambda;
28 using boost::phoenix::ref;
29 using boost::phoenix::arg_names::arg1;
30
31 std::vector<int> v;
32 for (int i = 1; i < 10; i++)
33 v.push_back(x: i);
34
35 int x = 0;
36 for_each(a0: arg1, a1: lambda[ref(t&: x) += arg1])(v);
37 BOOST_TEST(x == 45);
38 return;
39 }
40
41}
42
43int main()
44{
45 for_each_test();
46 boost::report_errors();
47}
48

source code of boost/libs/phoenix/test/algorithm/for_each2.cpp