1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3
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 ==============================================================================*/
7 #include <boost/detail/lightweight_test.hpp>
8 #include <boost/fusion/container/vector/vector.hpp>
9 #include <boost/fusion/container/vector/vector_iterator.hpp>
10 #include <boost/fusion/adapted/mpl.hpp>
11 #include <boost/fusion/sequence/io/out.hpp>
12 #include <boost/fusion/sequence/comparison/equal_to.hpp>
13 #include <boost/fusion/container/generation/make_vector.hpp>
14 #include <boost/fusion/algorithm/transformation/erase.hpp>
15 #include <boost/mpl/vector_c.hpp>
16 #include <boost/mpl/begin_end.hpp>
17 #include <boost/mpl/advance.hpp>
18 #include <boost/mpl/int.hpp>
19
20 int
main()21 main()
22 {
23 using namespace boost::fusion;
24 using boost::mpl::vector_c;
25 using boost::mpl::begin;
26 using boost::mpl::advance;
27 using boost::mpl::int_;
28
29 std::cout << tuple_open('[');
30 std::cout << tuple_close(']');
31 std::cout << tuple_delimiter(", ");
32
33 /// Testing erase
34
35 {
36 typedef vector<int, char, double, char const*> vector_type;
37 vector_type t1(1, 'x', 3.3, "Ruby");
38 vector_iterator<vector_type, 2> pos(t1);
39
40 std::cout << erase(t1, pos) << std::endl;
41 BOOST_TEST((erase(t1, pos) == make_vector(1, 'x', std::string("Ruby"))));
42 BOOST_TEST((erase(t1, end(t1)) == make_vector(1, 'x', 3.3, std::string("Ruby"))));
43 }
44
45 {
46 typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
47 typedef boost::mpl::begin<mpl_vec>::type mpl_vec_begin;
48 typedef boost::mpl::advance<mpl_vec_begin, int_<3> >::type mpl_vec_at3;
49 typedef boost::mpl::next<mpl_vec_begin>::type n1;
50 typedef boost::mpl::next<n1>::type n2;
51 typedef boost::mpl::next<n2>::type n3;
52
53 BOOST_STATIC_ASSERT((boost::is_same<mpl_vec_at3, n3>::value));
54
55
56 std::cout << erase(mpl_vec(), mpl_vec_at3()) << std::endl;
57 BOOST_TEST((erase(mpl_vec(), mpl_vec_at3())
58 == make_vector(1, 2, 3, 5)));
59 }
60
61 return boost::report_errors();
62 }
63
64