1 /*=============================================================================
2 Phoenix V1.2.1
3 Copyright (c) 2001-2003 Joel de Guzman
4
5 Use, modification and distribution is subject to the Boost Software
6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9 #include <iostream>
10 #include <string>
11 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/spirit/include/phoenix1_tuples.hpp>
13
14 using namespace phoenix;
15 using namespace phoenix::tuple_index_names;
16 using std::cout;
17 using std::endl;
18 using std::string;
19
20 int
main()21 main()
22 {
23 {
24 typedef tuple<int, char> tuple_t;
25 tuple_t ttt(3, 'c');
26
27 tuple_element<0, tuple_t>::type& e0 = ttt[_1];
28 tuple_element<1, tuple_t>::type& e1 = ttt[_2];
29
30 BOOST_TEST(e0 == 3);
31 BOOST_TEST(e1 == 'c');
32
33 cout << e0 << endl;
34 cout << e1 << endl;
35 }
36
37 {
38 typedef tuple<int, char, char const*> tuple_t;
39 tuple_t ttt(3, 'c', "hello world");
40 cout << ttt.length << endl;
41
42 tuple_element<0, tuple_t>::type& e0 = ttt[_1];
43 tuple_element<1, tuple_t>::type& e1 = ttt[_2];
44 tuple_element<2, tuple_t>::type& e2 = ttt[_3];
45
46 BOOST_TEST(e0 == 3);
47 BOOST_TEST(e1 == 'c');
48 BOOST_TEST(string(e2) == "hello world");
49
50 cout << e0 << endl;
51 cout << e1 << endl;
52 cout << e2 << endl;
53 }
54
55 return boost::report_errors();
56 }
57
58