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/adapted/mpl.hpp>
10 #include <boost/fusion/sequence/io/out.hpp>
11 #include <boost/fusion/sequence/comparison/equal_to.hpp>
12 #include <boost/fusion/sequence/intrinsic/at.hpp>
13 #include <boost/fusion/container/generation/make_vector.hpp>
14 #include <boost/fusion/algorithm/transformation/push_back.hpp>
15 #include <boost/fusion/algorithm/iteration/for_each.hpp>
16 #include <boost/mpl/vector_c.hpp>
17 #include <string>
18 
19 struct plus_one
20 {
21     template <typename T>
operator ()plus_one22     void operator()(T& v) const
23     {
24         v += 1;
25     }
26 };
27 
28 int
main()29 main()
30 {
31     using namespace boost::fusion;
32 
33     std::cout << tuple_open('[');
34     std::cout << tuple_close(']');
35     std::cout << tuple_delimiter(", ");
36 
37 /// Testing push_back
38 
39     {
40         char const* s = "Ruby";
41         typedef vector<int, char, double, char const*> vector_type;
42         vector_type t1(1, 'x', 3.3, s);
43 
44         {
45             std::cout << push_back(t1, 123456) << std::endl;
46             BOOST_TEST((push_back(t1, 123456)
47                 == make_vector(1, 'x', 3.3, s, 123456)));
48         }
49 
50         {
51             std::cout << push_back(t1, "funny") << std::endl;
52             BOOST_TEST((push_back(t1, "funny")
53                 == make_vector(1, 'x', 3.3, s, std::string("funny"))));
54         }
55 
56         {
57             std::cout << push_back(t1, t1) << std::endl;
58             BOOST_TEST((push_back(t1, t1)
59                 == make_vector(1, 'x', 3.3, s, t1)));
60         }
61     }
62 
63     {
64         typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
65         std::cout << boost::fusion::push_back(mpl_vec(), boost::mpl::int_<6>()) << std::endl;
66         BOOST_TEST((boost::fusion::push_back(mpl_vec(), boost::mpl::int_<6>())
67             == make_vector(1, 2, 3, 4, 5, 6)));
68     }
69 
70     return boost::report_errors();
71 }
72 
73