• 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/map/convert.hpp>
13 #include <boost/fusion/container/vector/convert.hpp>
14 #include <boost/fusion/algorithm/transformation/push_back.hpp>
15 #include <boost/fusion/sequence/comparison/equal_to.hpp>
16 #include <boost/fusion/sequence/intrinsic/at_key.hpp>
17 #include <boost/fusion/sequence/io/out.hpp>
18 #include <boost/fusion/support/pair.hpp>
19 
20 int
main()21 main()
22 {
23     using namespace boost::fusion;
24     using namespace boost;
25 
26     std::cout << tuple_open('[');
27     std::cout << tuple_close(']');
28     std::cout << tuple_delimiter(", ");
29 
30     {
31         vector0<> empty;
32         std::cout << as_map(make_list(make_pair<int>('X'), make_pair<double>("Men"))) << std::endl;
33         std::cout << as_map(push_back(empty, make_pair<int>(999))) << std::endl;
34     }
35 
36     {
37         typedef pair<int, char> p1;
38         typedef pair<double, std::string> p2;
39         boost::fusion::result_of::as_map<list<p1, p2> >::type map(make_pair<int>('X'), make_pair<double>("Men"));
40         std::cout << at_key<int>(map) << std::endl;
41         std::cout << at_key<double>(map) << std::endl;
42         BOOST_TEST(at_key<int>(map) == 'X');
43         BOOST_TEST(at_key<double>(map) == "Men");
44     }
45 
46     {
47         // test conversion
48         typedef map<
49             pair<int, char>
50           , pair<double, std::string> >
51         map_type;
52 
53         map_type m(make_vector(make_pair<int>('X'), make_pair<double>("Men")));
54         BOOST_TEST(as_vector(m) == make_vector(make_pair<int>('X'), make_pair<double>("Men")));
55         m = (make_vector(make_pair<int>('X'), make_pair<double>("Men"))); // test assign
56         BOOST_TEST(as_vector(m) == make_vector(make_pair<int>('X'), make_pair<double>("Men")));
57     }
58 
59     return boost::report_errors();
60 }
61 
62