| 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 |
| 14 | main() |
| 15 | { |
| 16 | using phoenix::arg_names::arg1; |
| 17 | using phoenix::arg_names::arg2; |
| 18 | { |
| 19 | bool x = false; |
| 20 | bool y = true; |
| 21 | |
| 22 | BOOST_TEST((!arg1)(x) == true); |
| 23 | BOOST_TEST((!arg1)(y) == false); |
| 24 | BOOST_TEST((arg1 || arg2)(x, y) == true); |
| 25 | BOOST_TEST((arg1 && arg2)(x, y) == false); |
| 26 | |
| 27 | // short circuiting: |
| 28 | int i = 1234; |
| 29 | (arg1 || (arg2 = 4567))(y, i); |
| 30 | BOOST_TEST(i == 1234); |
| 31 | (arg1 && (arg2 = 4567))(y, i); |
| 32 | BOOST_TEST(i == 4567); |
| 33 | } |
| 34 | |
| 35 | return boost::report_errors(); |
| 36 | } |
| 37 |
