Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/spirit/phoenix/test/tuples_tests.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.4 KB
Line 
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 <cassert>
12#include <boost/spirit/phoenix/tuples.hpp>
13
14using namespace std;
15using namespace phoenix;
16using namespace phoenix;
17using namespace phoenix::tuple_index_names;
18
19int
20main()
21{
22    {
23        typedef tuple<int, char> tuple_t;
24        tuple_t ttt(3, 'c');
25
26        tuple_element<0, tuple_t>::type& e0 = ttt[_1];
27        tuple_element<1, tuple_t>::type& e1 = ttt[_2];
28
29        assert(e0 == 3);
30        assert(e1 == 'c');
31
32        cout << e0 << endl;
33        cout << e1 << endl;
34    }
35
36    {
37        typedef tuple<int, char, char const*> tuple_t;
38        tuple_t ttt(3, 'c', "hello world");
39        cout << ttt.length << endl;
40
41        tuple_element<0, tuple_t>::type& e0 = ttt[_1];
42        tuple_element<1, tuple_t>::type& e1 = ttt[_2];
43        tuple_element<2, tuple_t>::type& e2 = ttt[_3];
44
45        assert(e0 == 3);
46        assert(e1 == 'c');
47        assert(string(e2) == "hello world");
48
49        cout << e0 << endl;
50        cout << e1 << endl;
51        cout << e2 << endl;
52    }
53
54    return 0;
55}
56
Note: See TracBrowser for help on using the repository browser.