]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/scope/lambda_tests_phx2.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2007 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
12 #include <boost/detail/lightweight_test.hpp>
13 #include <boost/phoenix/core.hpp>
14 #include <boost/phoenix/operator.hpp>
15 #include <boost/phoenix/scope.hpp>
16 #include <boost/phoenix/function.hpp>
18 namespace boost
{ namespace phoenix
22 template <typename C
, typename F
>
28 template <typename C
, typename F
>
29 void operator()(C
& c
, F f
) const
31 std::for_each(c
.begin(), c
.end(), f
);
35 function
<for_each_impl
> const for_each
= for_each_impl();
39 template <typename C
, typename T
>
45 template <typename C
, typename T
>
46 void operator()(C
& c
, T
& x
) const
52 function
<push_back_impl
> const push_back
= push_back_impl();
55 using namespace boost::phoenix
;
56 using namespace boost::phoenix::arg_names
;
57 using namespace boost::phoenix::local_names
;
66 using boost::phoenix::for_each
;
68 int init
[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
69 std::vector
<int> v(init
, init
+10);
72 for_each(_1
, lambda(_a
= _2
)[_a
+= _1
])(v
, x
);
77 using boost::phoenix::for_each
;
78 using boost::phoenix::push_back
;
81 std::vector
<std::vector
<int> > v(10);
83 for_each(_1
, lambda(_a
= _2
)[push_back(_1
, _a
)])(v
, x
);
86 for_each(arg1
, lambda
[ref(y
) += _1
[0]])(v
);
89 return boost::report_errors();