]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/scope/let_tests_rest.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2007 Joel de Guzman
3 Copyright (c) 2015 John Fletcher
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 ==============================================================================*/
13 #include <boost/phoenix/core/limits.hpp>
15 #include <boost/detail/lightweight_test.hpp>
16 #include <boost/fusion/tuple.hpp>
17 #include <boost/phoenix/core.hpp>
18 #include <boost/phoenix/operator.hpp>
19 #include <boost/phoenix/function.hpp>
20 #include <boost/phoenix/fusion.hpp>
21 #include <boost/phoenix/scope.hpp>
25 namespace fusion
= boost::fusion
;
26 namespace mpl
= boost::mpl
;
31 using boost::phoenix::let
;
32 using boost::phoenix::val
;
33 using boost::phoenix::arg_names::_1
;
34 using boost::phoenix::arg_names::_2
;
35 using boost::phoenix::arg_names::_3
;
36 using boost::phoenix::local_names::_a
;
37 using boost::phoenix::local_names::_b
;
38 using boost::phoenix::local_names::_c
;
39 using boost::phoenix::local_names::_d
;
40 using boost::phoenix::local_names::_e
;
41 using boost::phoenix::local_names::_x
;
42 using boost::phoenix::local_names::_y
;
43 using boost::phoenix::local_names::_z
;
44 using boost::phoenix::placeholders::arg1
;
70 int x
= 1, y
= 10, z
= 13;
79 (x
, y
, z
) == x
+ y
+ z
101 let(_x
= _1
) // _x is a reference to x
108 BOOST_TEST(x
== 888 + 999);
115 let(_x = val(_1)) // _x holds x by value
122 BOOST_TEST(x == 999);
125 let(_x = val(_1)) // _x holds x by value
132 BOOST_TEST(x == 999);
137 let(_a
= 1, _b
= 2, _c
= 3, _d
= 4, _e
= 5)
139 _a
+ _b
+ _c
+ _d
+ _e
141 () == 1 + 2 + 3 + 4 + 5
145 #ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
154 // show that we can return a local from an outer scope
156 int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y);
162 // show that this code returns an lvalue
164 let(_a
= arg1
)[ _a
](i
)++;
169 // show that what you put in is what you get out
171 int& j
= let(_a
= arg1
)[_a
](i
);
172 BOOST_TEST(&i
== &j
);
176 using boost::phoenix::at_c
;
178 boost::fusion::tuple
<int, int> t
= boost::fusion::make_tuple(0, 1);
179 int i
= let(_a
= at_c
<0>(_1
))[_a
](t
);
181 BOOST_TEST( i
== 0 );
186 let(_a
= _1
)[_a
= _2
](i
, 2);
190 return boost::report_errors();