1 /*=============================================================================
2 Copyright (c) 2001-2011 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/config.hpp>
12 #include <boost/fusion/support/sequence_base.hpp>
13 #include <boost/fusion/support/unused.hpp>
14 #include <boost/fusion/iterator/equal_to.hpp>
15 #include <boost/fusion/view/detail/strictest_traversal.hpp>
16 #include <boost/fusion/view/zip_view/detail/begin_impl.hpp>
17 #include <boost/fusion/view/zip_view/detail/end_impl.hpp>
18 #include <boost/fusion/view/zip_view/detail/size_impl.hpp>
19 #include <boost/fusion/view/zip_view/detail/at_impl.hpp>
20 #include <boost/fusion/view/zip_view/detail/value_at_impl.hpp>
21 #include <boost/fusion/container/vector/convert.hpp>
22 #include <boost/fusion/algorithm/query/find_if.hpp>
23 #include <boost/fusion/sequence/intrinsic/end.hpp>
24 #include <boost/fusion/sequence/intrinsic/size.hpp>
25 #include <boost/fusion/mpl.hpp>
26 #include <boost/fusion/algorithm/transformation/remove.hpp>
28 #include <boost/mpl/assert.hpp>
29 #include <boost/mpl/not.hpp>
30 #include <boost/mpl/placeholders.hpp>
31 #include <boost/mpl/transform_view.hpp>
32 #include <boost/mpl/at.hpp>
33 #include <boost/mpl/find_if.hpp>
34 #include <boost/mpl/equal_to.hpp>
35 #include <boost/mpl/bool.hpp>
36 #include <boost/mpl/eval_if.hpp>
38 #include <boost/type_traits/remove_reference.hpp>
39 #include <boost/type_traits/is_reference.hpp>
41 #include <boost/config.hpp>
43 namespace boost { namespace fusion {
47 template<typename Sequences>
49 : 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>
54 template<typename Params>
57 template<typename Seq>
58 struct result<seq_ref_size(Seq)>
60 static int const high_int = static_cast<int>(
61 (static_cast<unsigned>(~0) >> 1) - 1);
63 typedef typename remove_reference<Seq>::type SeqClass;
65 typedef typename mpl::eval_if<
66 traits::is_forward<SeqClass>,
67 result_of::size<SeqClass>,
68 mpl::int_<high_int> >::type type;
71 // never called, but needed for decltype-based result_of (C++0x)
72 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
73 template<typename Seq>
74 BOOST_FUSION_GPU_ENABLED
75 typename result<seq_ref_size(Seq)>::type
76 operator()(Seq&&) const;
85 template<typename Lhs, typename Rhs>
86 struct result<poly_min(Lhs, Rhs)>
88 typedef typename remove_reference<Lhs>::type lhs;
89 typedef typename remove_reference<Rhs>::type rhs;
90 typedef typename mpl::min<lhs, rhs>::type type;
93 // never called, but needed for decltype-based result_of (C++0x)
94 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
95 template<typename Lhs, typename Rhs>
96 BOOST_FUSION_GPU_ENABLED
97 typename result<poly_min(Lhs, Rhs)>::type
98 operator()(Lhs&&, Rhs&&) const;
102 template<typename Sequences>
105 typedef typename result_of::transform<Sequences, detail::seq_ref_size>::type sizes;
106 typedef typename result_of::fold<sizes, typename result_of::front<sizes>::type, detail::poly_min>::type type;
111 struct fusion_sequence_tag;
113 template<typename Sequences>
114 struct zip_view : sequence_base< zip_view<Sequences> >
116 typedef typename result_of::remove<Sequences, unused_type const&>::type real_sequences;
117 BOOST_MPL_ASSERT((detail::all_references<Sequences>));
118 typedef typename detail::strictest_traversal<real_sequences>::type category;
119 typedef zip_view_tag fusion_tag;
120 typedef fusion_sequence_tag tag; // this gets picked up by MPL
121 typedef mpl::true_ is_view;
122 typedef typename fusion::result_of::as_vector<Sequences>::type sequences;
123 typedef typename detail::min_size<real_sequences>::type size;
125 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
127 const Sequences& seqs)
131 sequences sequences_;