]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/scope/more_let_tests1.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::local_names::_a
;
36 using boost::phoenix::local_names::_b
;
39 // show that we can return a local from an outer scope
41 #if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__
42 int x
= (let(_a
= _2
)[let(_b
= _1
)[ _a
]])(y
,1);
44 int x
= (let(_a
= 1)[let(_b
= _1
)[ _a
]])(y
);
49 // show that we can return a local from an inner scope
51 int x
= (let(_a
= 0)[let(_b
= _1
)[ _b
]])(y
);
56 // show that we can return a local from an outer scope
58 #if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__
59 int x
= (let(_a
= 1)[let(_b
= _a
)[ _a
]])();
61 int x
= (let(_a
= _1
)[let(_b
= _a
)[ _a
]])(1);
66 // show that we can return a local from an inner scope
68 #if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__
69 int x
= (let(_a
= _1
)[let(_b
= _a
)[ _b
]])(1);
71 int x
= (let(_a
= 1)[let(_b
= _a
)[ _b
]])();
76 // show that we can return a local from an outer scope
78 int x
= (let(_a
= _1
)[let(_b
= _a
)[ _a
]])(y
);
83 // show that we can return a local from an inner scope
85 int x
= (let(_a
= _1
)[let(_b
= _a
)[ _b
]])(y
);
90 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++
91 // Be very careful. Some of these cases give a silly answer
92 // with clang 3.4 with C++03 and work for C++11.
93 // gcc 4.8.2 seems O.K. both ways. Oh dear.
94 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++
97 int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y);
98 //std::cout << x << " P1A "; //clang - empty memory
103 int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y);
104 //std::cout << x << " P1B "; //clang - 42 value- one step better
109 int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y);
110 //std::cout << x << " P2A "; //clang - 42 value - one step better
115 int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y);
116 //std::cout << x << " P2B "; //clang - 42 value - one step better
121 int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y);
122 //std::cout << x << " P3 "; //clang - OK - one step better still
128 int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y);
129 // std::cout << x << " Q "; // clang 4201472
134 return boost::report_errors();