| 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 <iostream> |
| 8 | #include <boost/detail/lightweight_test.hpp> |
| 9 | #include <boost/phoenix/core.hpp> |
| 10 | #include <boost/phoenix/operator.hpp> |
| 11 | |
| 12 | namespace phoenix = boost::phoenix; |
| 13 | |
| 14 | int |
| 15 | main() |
| 16 | { |
| 17 | using phoenix::ref; |
| 18 | using phoenix::val; |
| 19 | using phoenix::arg_names::arg1; |
| 20 | using std::cout; |
| 21 | |
| 22 | { |
| 23 | int x; |
| 24 | int y; |
| 25 | |
| 26 | x = 123; |
| 27 | y = 123; |
| 28 | (ref(t&: x) &= 456)(); |
| 29 | y &= 456; |
| 30 | BOOST_TEST(x == y); |
| 31 | |
| 32 | x = 123; |
| 33 | y = 123; |
| 34 | (ref(t&: x) |= 456)(); |
| 35 | y |= 456; |
| 36 | BOOST_TEST(x == y); |
| 37 | |
| 38 | x = 123; |
| 39 | y = 123; |
| 40 | (ref(t&: x) ^= 456)(); |
| 41 | y ^= 456; |
| 42 | BOOST_TEST(x == y); |
| 43 | |
| 44 | x = 123; |
| 45 | y = 123; |
| 46 | (ref(t&: x) <<= 4)(); |
| 47 | y <<= 4; |
| 48 | BOOST_TEST(x == y); |
| 49 | |
| 50 | x = 1230000; |
| 51 | y = 1230000; |
| 52 | (ref(t&: x) >>= 4)(); |
| 53 | y >>= 4; |
| 54 | BOOST_TEST(x == y); |
| 55 | |
| 56 | int& r1 = (ref(t&: x) &= 456)(); // should be an lvalue |
| 57 | int& r2 = (ref(t&: x) |= 456)(); // should be an lvalue |
| 58 | int& r3 = (ref(t&: x) ^= 456)(); // should be an lvalue |
| 59 | int& r4 = (ref(t&: x) <<= 4)(); // should be an lvalue |
| 60 | int& r5 = (ref(t&: x) >>= 4)(); // should be an lvalue |
| 61 | BOOST_TEST(&r1 == &r2 && &r2 == &r3 && &r3 == &r4 && &r4 == &r5); |
| 62 | } |
| 63 | |
| 64 | { |
| 65 | BOOST_TEST((val(123) & 456)() == (123 & 456)); |
| 66 | BOOST_TEST((val(123) | 456)() == (123 | 456)); |
| 67 | BOOST_TEST((val(123) ^ 456)() == (123 ^ 456)); |
| 68 | BOOST_TEST((val(123) << 4)() == (123 << 4)); |
| 69 | BOOST_TEST((val(1230000) >> 4)() == (1230000 >> 4)); |
| 70 | |
| 71 | char const* s = "Yabadabadoo!!!\n"; |
| 72 | (cout << arg1)(s); |
| 73 | } |
| 74 | |
| 75 | return boost::report_errors(); |
| 76 | } |
| 77 |
