fix doc example typo
[boost.git] / boost / fusion / view / zip_view / zip_view.hpp
blob340feafb30e5f1b49f8ca9ac6657f557f6a83e06
1 /*=============================================================================
2 Copyright (c) 2001-2006 Joel de Guzman
3 Copyright (c) 2006 Dan Marsden
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 #if !defined(FUSION_ZIP_VIEW_23012006_0813)
9 #define FUSION_ZIP_VIEW_23012006_0813
11 #include <boost/fusion/support/sequence_base.hpp>
12 #include <boost/fusion/support/unused.hpp>
13 #include <boost/fusion/iterator/equal_to.hpp>
14 #include <boost/fusion/view/detail/strictest_traversal.hpp>
15 #include <boost/fusion/view/zip_view/detail/begin_impl.hpp>
16 #include <boost/fusion/view/zip_view/detail/end_impl.hpp>
17 #include <boost/fusion/view/zip_view/detail/size_impl.hpp>
18 #include <boost/fusion/view/zip_view/detail/at_impl.hpp>
19 #include <boost/fusion/view/zip_view/detail/value_at_impl.hpp>
20 #include <boost/fusion/container/vector/convert.hpp>
21 #include <boost/fusion/algorithm/query/find_if.hpp>
22 #include <boost/fusion/sequence/intrinsic/end.hpp>
23 #include <boost/fusion/sequence/intrinsic/size.hpp>
24 #include <boost/fusion/mpl.hpp>
25 #include <boost/fusion/algorithm/transformation/remove.hpp>
27 #include <boost/mpl/assert.hpp>
28 #include <boost/mpl/not.hpp>
29 #include <boost/mpl/placeholders.hpp>
30 #include <boost/mpl/transform_view.hpp>
31 #include <boost/mpl/at.hpp>
32 #include <boost/mpl/find_if.hpp>
33 #include <boost/mpl/equal_to.hpp>
34 #include <boost/mpl/bool.hpp>
35 #include <boost/mpl/eval_if.hpp>
37 #include <boost/type_traits/remove_reference.hpp>
38 #include <boost/type_traits/is_reference.hpp>
40 namespace boost { namespace fusion {
42 namespace detail
44 template<typename Sequences>
45 struct all_references
46 : fusion::result_of::equal_to<typename fusion::result_of::find_if<Sequences, mpl::not_<is_reference<mpl::_> > >::type, typename fusion::result_of::end<Sequences>::type>
47 {};
49 struct seq_ref_size
51 template<typename Params>
52 struct result;
54 template<typename Seq>
55 struct result<seq_ref_size(Seq)>
57 static int const high_int = static_cast<int>(
58 (static_cast<unsigned>(~0) >> 1) - 1);
60 typedef typename remove_reference<Seq>::type SeqClass;
62 typedef typename mpl::eval_if<
63 traits::is_forward<SeqClass>,
64 result_of::size<SeqClass>,
65 mpl::int_<high_int> >::type type;
69 struct poly_min
71 template<typename T>
72 struct result;
74 template<typename Lhs, typename Rhs>
75 struct result<poly_min(Lhs, Rhs)>
77 typedef typename remove_reference<Lhs>::type lhs;
78 typedef typename remove_reference<Rhs>::type rhs;
79 typedef typename mpl::min<lhs, rhs>::type type;
83 template<typename Sequences>
84 struct min_size
86 typedef typename result_of::transform<Sequences, detail::seq_ref_size>::type sizes;
87 typedef typename result_of::fold<sizes, typename result_of::front<sizes>::type, detail::poly_min>::type type;
91 struct zip_view_tag;
92 struct fusion_sequence_tag;
94 template<typename Sequences>
95 struct zip_view : sequence_base< zip_view<Sequences> >
97 typedef typename result_of::remove<Sequences, unused_type const&>::type real_sequences;
98 BOOST_MPL_ASSERT((detail::all_references<Sequences>));
99 typedef typename detail::strictest_traversal<real_sequences>::type category;
100 typedef zip_view_tag fusion_tag;
101 typedef fusion_sequence_tag tag; // this gets picked up by MPL
102 typedef mpl::true_ is_view;
103 typedef typename fusion::result_of::as_vector<Sequences>::type sequences;
104 typedef typename detail::min_size<real_sequences>::type size;
106 zip_view(
107 const Sequences& seqs)
108 : sequences_(seqs)
111 sequences sequences_;
115 #endif