]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/statement/switch_tests.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2007 Joel de Guzman
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 ==============================================================================*/
11 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/phoenix/core.hpp>
13 #include <boost/phoenix/statement.hpp>
14 #include <boost/phoenix/operator.hpp>
19 using boost::phoenix::arg_names::_1
;
20 using boost::phoenix::case_
;
21 using boost::phoenix::switch_
;
22 using boost::phoenix::ref
;
23 using boost::phoenix::val
;
30 int init
[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
31 vector
<int> v(init
, init
+10);
33 for_each(v
.begin(), v
.end(),
36 // wierd case, why not just use if(...), but valid, nonetheless
37 case_
<4>(cout
<< val("<4>") << endl
)
42 for_each(v
.begin(), v
.end(),
45 // wierd case, but valid, nonetheless
46 default_(cout
<< val("<any...>") << endl
)
52 for_each(v
.begin(), v
.end(),
55 case_
<1>(cout
<< val("<1>") << endl
),
56 case_
<2>(cout
<< val("<2>") << endl
),
57 case_
<3>(cout
<< val("<3>") << endl
),
58 case_
<4>(cout
<< val("<4>") << endl
)
64 for_each(v
.begin(), v
.end(),
67 case_
<1>(cout
<< val("<1>") << endl
),
68 case_
<2>(cout
<< val("<2>") << endl
),
69 case_
<3>(cout
<< val("<3>") << endl
),
70 case_
<4>(cout
<< val("<4>") << endl
),
71 default_(cout
<< val("<over 4>") << endl
)
75 return boost::report_errors();