PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/phoenix/test/operator/if_else_tests.cpp

http://hadesmem.googlecode.com/
C++ | 36 lines | 23 code | 6 blank | 7 comment | 4 complexity | 49df822880dcd26f56f100ca7e746601 MD5 | raw file
 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
11namespace phoenix = boost::phoenix;
12
13int
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}