comparison DEPENDENCIES/generic/include/boost/fusion/view/zip_view/zip_view.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2006 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 #if !defined(FUSION_ZIP_VIEW_23012006_0813)
9 #define FUSION_ZIP_VIEW_23012006_0813
10
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>
26
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>
36
37 #include <boost/type_traits/remove_reference.hpp>
38 #include <boost/type_traits/is_reference.hpp>
39
40 #include <boost/config.hpp>
41
42 namespace boost { namespace fusion {
43
44 namespace detail
45 {
46 template<typename Sequences>
47 struct all_references
48 : 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>
49 {};
50
51 struct seq_ref_size
52 {
53 template<typename Params>
54 struct result;
55
56 template<typename Seq>
57 struct result<seq_ref_size(Seq)>
58 {
59 static int const high_int = static_cast<int>(
60 (static_cast<unsigned>(~0) >> 1) - 1);
61
62 typedef typename remove_reference<Seq>::type SeqClass;
63
64 typedef typename mpl::eval_if<
65 traits::is_forward<SeqClass>,
66 result_of::size<SeqClass>,
67 mpl::int_<high_int> >::type type;
68 };
69
70 // never called, but needed for decltype-based result_of (C++0x)
71 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
72 template<typename Seq>
73 typename result<seq_ref_size(Seq)>::type
74 operator()(Seq&&) const;
75 #endif
76 };
77
78 struct poly_min
79 {
80 template<typename T>
81 struct result;
82
83 template<typename Lhs, typename Rhs>
84 struct result<poly_min(Lhs, Rhs)>
85 {
86 typedef typename remove_reference<Lhs>::type lhs;
87 typedef typename remove_reference<Rhs>::type rhs;
88 typedef typename mpl::min<lhs, rhs>::type type;
89 };
90
91 // never called, but needed for decltype-based result_of (C++0x)
92 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
93 template<typename Lhs, typename Rhs>
94 typename result<poly_min(Lhs, Rhs)>::type
95 operator()(Lhs&&, Rhs&&) const;
96 #endif
97 };
98
99 template<typename Sequences>
100 struct min_size
101 {
102 typedef typename result_of::transform<Sequences, detail::seq_ref_size>::type sizes;
103 typedef typename result_of::fold<sizes, typename result_of::front<sizes>::type, detail::poly_min>::type type;
104 };
105 }
106
107 struct zip_view_tag;
108 struct fusion_sequence_tag;
109
110 template<typename Sequences>
111 struct zip_view : sequence_base< zip_view<Sequences> >
112 {
113 typedef typename result_of::remove<Sequences, unused_type const&>::type real_sequences;
114 BOOST_MPL_ASSERT((detail::all_references<Sequences>));
115 typedef typename detail::strictest_traversal<real_sequences>::type category;
116 typedef zip_view_tag fusion_tag;
117 typedef fusion_sequence_tag tag; // this gets picked up by MPL
118 typedef mpl::true_ is_view;
119 typedef typename fusion::result_of::as_vector<Sequences>::type sequences;
120 typedef typename detail::min_size<real_sequences>::type size;
121
122 zip_view(
123 const Sequences& seqs)
124 : sequences_(seqs)
125 {};
126
127 sequences sequences_;
128 };
129 }}
130
131 #endif