• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*==============================================================================
2     Copyright (c) 2013 Jamboree
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/sequence/io/out.hpp>
10 #include <boost/fusion/sequence/comparison/equal_to.hpp>
11 #include <boost/fusion/container/generation/make_vector.hpp>
12 #include <boost/fusion/sequence/intrinsic/begin.hpp>
13 #include <boost/fusion/sequence/intrinsic/end.hpp>
14 #include <boost/fusion/sequence/intrinsic/at.hpp>
15 #include <boost/fusion/sequence/intrinsic/size.hpp>
16 #include <boost/fusion/iterator/advance.hpp>
17 #include <boost/fusion/iterator/deref.hpp>
18 #include <boost/fusion/iterator/distance.hpp>
19 #include <boost/fusion/algorithm/auxiliary/copy.hpp>
20 #include <boost/fusion/algorithm/transformation/flatten.hpp>
21 
22 
main()23 int main()
24 {
25     using namespace boost::fusion;
26 
27     {
28         typedef vector<int, int, vector<int, int>, int> sequence_type;
29         sequence_type seq(1, 2, make_vector(3, 4), 5);
30 
31         BOOST_TEST((boost::fusion::size(flatten(seq)) == 5));
32     }
33 
34     {
35         typedef vector<int, int, vector<int, int>, int> sequence_type;
36         sequence_type seq(1, 2, make_vector(3, 4), 5);
37         std::cout << flatten(seq) << std::endl;
38         BOOST_TEST((flatten(seq) == make_vector(1, 2, 3, 4, 5)));
39     }
40 
41     {
42         std::cout << flatten(make_vector(1, 2, make_vector(3, 4), 5)) << std::endl;
43         BOOST_TEST((flatten(make_vector(1, 2, make_vector(3, 4), 5)) == make_vector(1, 2, 3, 4, 5)));
44     }
45 
46     {
47         typedef vector<int, int, vector<int, int>, int> sequence_type;
48         sequence_type seq;
49         result_of::flatten<sequence_type>::type flat(flatten(seq));
50         copy(make_vector(1, 2, 3, 4, 5), flat);
51         std::cout << seq << std::endl;
52         BOOST_TEST((seq == make_vector(1, 2, make_vector(3, 4), 5)));
53     }
54 
55     return boost::report_errors();
56 }
57 
58