• 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/set/convert.hpp>
13 #include <boost/fusion/container/list/convert.hpp>
14 #include <boost/fusion/container/vector/convert.hpp>
15 #include <boost/fusion/algorithm/transformation/push_back.hpp>
16 #include <boost/fusion/sequence/comparison/equal_to.hpp>
17 #include <boost/fusion/sequence/intrinsic/at_key.hpp>
18 #include <boost/fusion/sequence/io/out.hpp>
19 #include <boost/mpl/vector_c.hpp>
20 
21 int
main()22 main()
23 {
24     using namespace boost::fusion;
25     using namespace boost;
26 
27     std::cout << tuple_open('[');
28     std::cout << tuple_close(']');
29     std::cout << tuple_delimiter(", ");
30 
31     {
32         vector0<> empty;
33         std::cout << as_set(make_list(1, 1.23, "harru")) << std::endl;
34         std::cout << as_set(push_back(empty, 999)) << std::endl;
35 
36         BOOST_TEST(as_list(as_set(make_list(1, 1.23, "harru")))
37             == make_list(1, 1.23, std::string("harru")));
38         BOOST_TEST(as_list(as_set(push_back(empty, 999)))
39             == push_back(empty, 999));
40     }
41 
42     {
43         boost::fusion::result_of::as_set<list<int, double, std::string> >::type set(1, 1.23, "harru");
44         std::cout << at_key<int>(set) << std::endl;
45         BOOST_TEST(at_key<int>(set) == 1);
46     }
47 
48     {
49         std::cout << as_set(mpl::vector_c<int, 1, 2, 3, 4, 5>()) << std::endl;
50         BOOST_TEST((as_list(as_set(mpl::vector_c<int, 1, 2, 3, 4, 5>()))
51             == mpl::vector_c<int, 1, 2, 3, 4, 5>()));
52     }
53 
54     {
55         // test conversion
56         set<int, std::string> s(make_vector(123, "harru"));
57         BOOST_TEST(as_vector(s) == make_vector(123, "harru"));
58         s = (make_vector(235, "hola")); // test assign
59         BOOST_TEST(as_vector(s) == make_vector(235, "hola"));
60     }
61 
62     return boost::report_errors();
63 }
64 
65