]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/phoenix/test/scope/lambda_tests2a.cpp
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / boost / libs / phoenix / test / scope / lambda_tests2a.cpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2001-2007 Joel de Guzman
3 Copyright (c) 2014 John Fletcher
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7==============================================================================*/
8#include <iostream>
9#include <cmath>
10#include <algorithm>
11#include <vector>
12
13#include <typeinfo>
14
15#include <boost/detail/lightweight_test.hpp>
16#include <boost/phoenix/core.hpp>
17#include <boost/phoenix/operator.hpp>
18#include <boost/phoenix/function.hpp>
19//#include <boost/phoenix/bind.hpp>
20#include <boost/phoenix/scope.hpp>
21#include <boost/phoenix/stl/algorithm.hpp>
22#include <boost/phoenix/stl/container.hpp>
23
24int
25main()
26{
27 using boost::phoenix::lambda;
28 using boost::phoenix::let;
29 using boost::phoenix::ref;
30 using boost::phoenix::val;
31 using boost::phoenix::arg_names::_1;
32 using boost::phoenix::arg_names::_2;
33 using boost::phoenix::local_names::_a;
34 // using boost::phoenix::local_names::_b;
35 using boost::phoenix::placeholders::arg1;
36
37 {
38 using boost::phoenix::for_each;
39 //#if (!defined(BOOST_MSVC) || (BOOST_MSVC < 1800))
40 int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
41 std::vector<int> v(init, init+10);
42
43 int x = 0;
44 for_each(_1, lambda(_a = _2)[_a += _1])(v, x);
45 BOOST_TEST(x == 55);
46 //#endif
47 }
48
49 {
50 using boost::phoenix::for_each;
51 using boost::phoenix::push_back;
52
53 //#if (!defined(BOOST_MSVC) || (BOOST_MSVC < 1800))
54 int x = 10;
55 std::vector<std::vector<int> > v(10);
56 for_each(_1, lambda(_a = _2)[push_back(_1, _a)])(v, x);
57
58 int y = 0;
59 for_each(arg1, lambda[ref(y) += _1[0]])(v);
60 BOOST_TEST(y == 100);
61 //#endif
62 }
63
64 return boost::report_errors();
65}
66