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 | |
19 | int main() |
20 | { |
21 | using boost::phoenix::lambda; |
22 | using boost::phoenix::ref; |
23 | using boost::phoenix::arg_names::_1; |
24 | using boost::phoenix::arg_names::_2; |
25 | using boost::phoenix::local_names::_a; |
26 | using boost::phoenix::placeholders::arg1; |
27 | |
28 | using boost::phoenix::for_each; |
29 | using boost::phoenix::push_back; |
30 | |
31 | int x = 10; |
32 | std::vector<std::vector<int> > v(10); |
33 | for_each(a0: _1, a1: lambda(_a = _2)[push_back(a0: _1, a1: _a)])(v, x); |
34 | |
35 | int y = 0; |
36 | for_each(a0: arg1, a1: lambda[ref(t&: y) += _1[0]])(v); |
37 | BOOST_TEST(y == 100); |
38 | |
39 | return boost::report_errors(); |
40 | } |
41 | |
42 |