1 /*=============================================================================
2 Copyright (c) 2001-2007 Joel de Guzman
3 Copyright (c) 2007 Dan Marsden
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #include <boost/detail/lightweight_test.hpp>
9 #include <boost/fusion/container/vector.hpp>
10 #include <boost/fusion/view/zip_view.hpp>
11 #include <boost/fusion/support/unused.hpp>
12 #include <boost/fusion/iterator.hpp>
13 #include <boost/fusion/sequence/intrinsic.hpp>
14
15 #include <boost/mpl/assert.hpp>
16 #include <boost/type_traits/is_same.hpp>
17
main()18 int main()
19 {
20 using namespace boost::fusion;
21 {
22 typedef vector2<int,int> int_vector;
23 typedef vector2<char,char> char_vector;
24 typedef vector<int_vector&, unused_type const&, char_vector&> seqs_type;
25 typedef zip_view<seqs_type> view;
26
27 int_vector iv(1,2);
28 char_vector cv('a','b');
29 seqs_type seq(iv, unused, cv);
30 view v(seq);
31
32 BOOST_TEST(at_c<0>(front(v)) == 1);
33 BOOST_TEST(at_c<2>(front(v)) == 'a');
34 BOOST_TEST(at_c<0>(back(v)) == 2);
35 BOOST_TEST(at_c<2>(back(v)) == 'b');
36
37 typedef boost::fusion::result_of::begin<view>::type first_iterator;
38 typedef boost::fusion::result_of::value_of<first_iterator>::type first_element;
39
40 typedef boost::fusion::result_of::at_c<first_element, 0>::type e0;
41 typedef boost::fusion::result_of::at_c<first_element, 2>::type e2;
42 BOOST_MPL_ASSERT((boost::is_same<e0, int&>));
43 BOOST_MPL_ASSERT((boost::is_same<e2, char&>));
44
45 BOOST_TEST(size(front(v)) == 3);
46
47 typedef boost::fusion::result_of::value_at_c<view, 0>::type first_value_at;
48 typedef boost::fusion::result_of::value_at_c<first_value_at, 0>::type v0;
49 typedef boost::fusion::result_of::value_at_c<first_value_at, 2>::type v2;
50
51 BOOST_MPL_ASSERT((boost::is_same<v0, int>));
52 BOOST_MPL_ASSERT((boost::is_same<v2, char>));
53
54 BOOST_TEST(at_c<0>(at_c<0>(v)) == 1);
55 BOOST_TEST(at_c<2>(at_c<0>(v)) == 'a');
56 }
57 return boost::report_errors();
58 }
59