• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2007 Joel de Guzman
3     Copyright (c) 2014      John Fletcher
4     Copyright (c) 2018      Kohei Takahsahi
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 #include <vector>
10 
11 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/phoenix/core.hpp>
13 #include <boost/phoenix/operator/self.hpp>
14 #include <boost/phoenix/operator/arithmetic.hpp>
15 #include <boost/phoenix/scope/lambda.hpp>
16 #include <boost/phoenix/stl/algorithm/iteration.hpp>
17 #include <boost/phoenix/stl/container.hpp>
18 
main()19 int main()
20 {
21     using boost::phoenix::lambda;
22     using boost::phoenix::arg_names::_1;
23     using boost::phoenix::arg_names::_2;
24     using boost::phoenix::local_names::_a;
25     using boost::phoenix::for_each;
26 
27     int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
28     std::vector<int> v(init, init+10);
29 
30     int x = 0;
31     for_each(_1, lambda(_a = _2)[_a += _1])(v, x);
32     BOOST_TEST(x == 55);
33 
34     return boost::report_errors();
35 }
36 
37