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#include <boost/typeof/std/ostream.hpp>
20
21namespace
22{
23
24 void for_test()
25 {
26 using boost::phoenix::for_;
27 using boost::phoenix::val;
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 //std::string test_str("(123456789)");
36 //std::ostringstream out;
37 int iii;
38 int x = 0;
39 int size = v.size();
40 for_(init: ref(t&: iii) = 0, cond: ref(t&: iii) < size, step: ++ref(t&: iii) )
41 [ ref(t&: x) += arg1[ref(t&: iii)] ] (v);
42 BOOST_TEST(x == 45);
43 return;
44 }
45
46}
47
48int main()
49{
50 for_test();
51 boost::report_errors();
52}
53

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