| 1 | /*============================================================================= |
|---|
| 2 | Copyright (c) 2003 Joel de Guzman |
|---|
| 3 | |
|---|
| 4 | Use, modification and distribution is subject to the Boost Software |
|---|
| 5 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 6 | http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 7 | ==============================================================================*/ |
|---|
| 8 | #include <boost/detail/lightweight_test.hpp> |
|---|
| 9 | #include <boost/spirit/fusion/sequence/tuple.hpp> |
|---|
| 10 | #include <boost/spirit/fusion/sequence/io.hpp> |
|---|
| 11 | #include <boost/spirit/fusion/sequence/equal_to.hpp> |
|---|
| 12 | #include <boost/spirit/fusion/sequence/make_tuple.hpp> |
|---|
| 13 | #include <boost/spirit/fusion/sequence/range.hpp> |
|---|
| 14 | |
|---|
| 15 | int |
|---|
| 16 | main() |
|---|
| 17 | { |
|---|
| 18 | using namespace boost::fusion; |
|---|
| 19 | |
|---|
| 20 | std::cout << tuple_open('['); |
|---|
| 21 | std::cout << tuple_close(']'); |
|---|
| 22 | std::cout << tuple_delimiter(", "); |
|---|
| 23 | |
|---|
| 24 | /// Testing range |
|---|
| 25 | |
|---|
| 26 | { |
|---|
| 27 | char const* s = "Ruby"; |
|---|
| 28 | typedef tuple<int, char, double, char const*> tuple_type; |
|---|
| 29 | tuple_type t1(1, 'x', 3.3, s); |
|---|
| 30 | |
|---|
| 31 | { |
|---|
| 32 | typedef tuple_iterator<1, tuple_type> i1t; |
|---|
| 33 | typedef tuple_iterator<3, tuple_type> i3t; |
|---|
| 34 | |
|---|
| 35 | i1t i1(t1); |
|---|
| 36 | i3t i3(t1); |
|---|
| 37 | |
|---|
| 38 | range<i1t, i3t> slice(i1, i3); |
|---|
| 39 | std::cout << slice << std::endl; |
|---|
| 40 | BOOST_TEST(slice == make_tuple('x', 3.3)); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | { |
|---|
| 44 | typedef tuple_iterator<0, tuple_type> i1t; |
|---|
| 45 | typedef tuple_iterator<0, tuple_type> i3t; |
|---|
| 46 | |
|---|
| 47 | i1t i1(t1); |
|---|
| 48 | i3t i3(t1); |
|---|
| 49 | |
|---|
| 50 | range<i1t, i3t> slice(i1, i3); |
|---|
| 51 | std::cout << slice << std::endl; |
|---|
| 52 | BOOST_TEST(slice == tuple<>()); |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | return boost::report_errors(); |
|---|
| 57 | } |
|---|
| 58 | |
|---|