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/algorithm/erase.hpp> |
---|
14 | #include <boost/mpl/vector_c.hpp> |
---|
15 | #include <boost/mpl/begin_end.hpp> |
---|
16 | #include <boost/mpl/advance.hpp> |
---|
17 | #include <boost/mpl/int.hpp> |
---|
18 | |
---|
19 | int |
---|
20 | main() |
---|
21 | { |
---|
22 | using namespace boost::fusion; |
---|
23 | using boost::mpl::vector_c; |
---|
24 | using boost::mpl::begin; |
---|
25 | using boost::mpl::advance; |
---|
26 | using boost::mpl::int_; |
---|
27 | |
---|
28 | std::cout << tuple_open('['); |
---|
29 | std::cout << tuple_close(']'); |
---|
30 | std::cout << tuple_delimiter(", "); |
---|
31 | |
---|
32 | /// Testing erase |
---|
33 | |
---|
34 | { |
---|
35 | char const* s = "Ruby"; |
---|
36 | typedef tuple<int, char, double, char const*> tuple_type; |
---|
37 | tuple_type t1(1, 'x', 3.3, s); |
---|
38 | tuple_iterator<2, tuple_type> pos(t1); |
---|
39 | |
---|
40 | std::cout << erase(t1, pos) << std::endl; |
---|
41 | BOOST_TEST((erase(t1, pos) == make_tuple(1, 'x', s))); |
---|
42 | } |
---|
43 | |
---|
44 | { |
---|
45 | typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec; |
---|
46 | typedef boost::mpl::begin<mpl_vec>::type mpl_vec_begin; |
---|
47 | typedef boost::mpl::advance<mpl_vec_begin, int_<3> >::type mpl_vec_at3; |
---|
48 | |
---|
49 | std::cout << erase(mpl_vec(), mpl_vec_at3()) << std::endl; |
---|
50 | BOOST_TEST((erase(mpl_vec(), mpl_vec_at3()) |
---|
51 | == make_tuple(1, 2, 3, 5))); |
---|
52 | } |
---|
53 | |
---|
54 | return boost::report_errors(); |
---|
55 | } |
---|
56 | |
---|