• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/container/generation/make_vector.hpp>
11 #include <boost/fusion/container/generation/make_list.hpp>
12 #include <boost/fusion/container/vector/convert.hpp>
13 #include <boost/fusion/algorithm/transformation/push_back.hpp>
14 #include <boost/fusion/sequence/comparison/equal_to.hpp>
15 #include <boost/fusion/sequence/io/out.hpp>
16 #include <boost/mpl/vector_c.hpp>
17 #include <string>
18 
19 int
main()20 main()
21 {
22     using namespace boost::fusion;
23     using namespace boost;
24 
25     std::cout << tuple_open('[');
26     std::cout << tuple_close(']');
27     std::cout << tuple_delimiter(", ");
28 
29     {
30         vector0<> empty;
31         std::cout << as_vector(make_list(1, 1.23, "harru")) << std::endl;
32         std::cout << as_vector(push_back(empty, 999)) << std::endl;
33 
34         BOOST_TEST(as_vector(make_list(1, 1.23, "harru")) == make_list(1, 1.23, std::string("harru")));
35         BOOST_TEST(as_vector(push_back(empty, 999)) == push_back(empty, 999));
36     }
37 
38     {
39         std::cout << as_vector(mpl::vector_c<int, 1, 2, 3, 4, 5>()) << std::endl;
40         BOOST_TEST((as_vector(mpl::vector_c<int, 1, 2, 3, 4, 5>())
41             == mpl::vector_c<int, 1, 2, 3, 4, 5>()));
42     }
43 
44     {
45         // test conversion
46         vector<int, std::string> v(make_list(123, "harru"));
47         BOOST_TEST(v == make_list(123, "harru"));
48         v = (make_list(235, "hola")); // test assign
49         BOOST_TEST(v == make_list(235, "hola"));
50     }
51 
52     return boost::report_errors();
53 }
54 
55