1 /*============================================================================= 2 Copyright (c) 2001-2007 Joel de Guzman 3 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 ==============================================================================*/ 7 #include <boost/detail/lightweight_test.hpp> 8 #include <boost/phoenix/core.hpp> 9 #include <boost/phoenix/operator.hpp> 10 11 namespace phoenix = boost::phoenix; 12 13 int main()14main() 15 { 16 //using phoenix::if_else; 17 using phoenix::ref; 18 using phoenix::val; 19 using phoenix::arg_names::arg1; 20 { 21 int x = 0; 22 int y = 0; 23 bool c = false; 24 25 BOOST_TEST(phoenix::if_else(arg1, 1234, 5678)(c) == 5678); 26 BOOST_TEST(phoenix::if_else(arg1, 1234, 'x')(c) == 'x'); 27 28 int& r = phoenix::if_else(arg1, ref(x), ref(y))(c); // should be an lvalue 29 BOOST_TEST(&y == &r); 30 31 (phoenix::if_else(arg1, ref(x), ref(y)) = 986754321)(c); 32 BOOST_TEST(y == 986754321); 33 } 34 35 return boost::report_errors(); 36 } 37