]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/scope/let_tests_157.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/phoenix/core/limits.hpp>
14 #include <boost/detail/lightweight_test.hpp>
15 #include <boost/fusion/tuple.hpp>
16 #include <boost/phoenix/core.hpp>
17 #include <boost/phoenix/operator.hpp>
18 #include <boost/phoenix/function.hpp>
19 #include <boost/phoenix/fusion.hpp>
20 #include <boost/phoenix/scope.hpp>
24 namespace fusion
= boost::fusion
;
25 namespace mpl
= boost::mpl
;
30 using boost::phoenix::let
;
31 using boost::phoenix::val
;
32 using boost::phoenix::arg_names::_1
;
33 using boost::phoenix::arg_names::_2
;
34 //using boost::phoenix::arg_names::_3;
35 using boost::phoenix::local_names::_a
;
36 using boost::phoenix::local_names::_b
;
37 //using boost::phoenix::local_names::_c;
38 //using boost::phoenix::local_names::_d;
39 //using boost::phoenix::local_names::_e;
40 //using boost::phoenix::local_names::_x;
41 //using boost::phoenix::local_names::_y;
42 //using boost::phoenix::local_names::_z;
43 //using boost::phoenix::placeholders::arg1;
69 int x = 1, y = 10, z = 13;
78 (x, y, z) == x + y + z
100 let(_x = _1) // _x is a reference to x
107 BOOST_TEST(x == 888 + 999);
114 let(_x = val(_1)) // _x holds x by value
121 BOOST_TEST(x == 999);
124 let(_x = val(_1)) // _x holds x by value
131 BOOST_TEST(x == 999);
136 let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5)
138 _a + _b + _c + _d + _e
140 () == 1 + 2 + 3 + 4 + 5
144 #ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
153 // show that we can return a local from an outer scope
155 #if defined(__OPTIMIZE__) && __OPTIMIZE__
156 int x
= (let(_a
= _2
)[let(_b
= _1
)[ _a
]])(y
,1);
158 int x
= (let(_a
= 1)[let(_b
= _1
)[ _a
]])(y
);
164 // show that this code returns an lvalue
166 let(_a = arg1)[ _a ](i)++;
171 // show that what you put in is what you get out
173 int& j = let(_a = arg1)[_a](i);
174 BOOST_TEST(&i == &j);
178 using boost::phoenix::at_c;
180 boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1);
181 int i = let(_a = at_c<0>(_1))[_a](t);
183 BOOST_TEST( i == 0 );
188 let(_a = _1)[_a = _2](i, 2);
192 return boost::report_errors();