Chris@16
|
1
|
Chris@16
|
2 #ifndef BOOST_MPL_PAIR_VIEW_HPP_INCLUDED
|
Chris@16
|
3 #define BOOST_MPL_PAIR_VIEW_HPP_INCLUDED
|
Chris@16
|
4
|
Chris@16
|
5 // Copyright David Abrahams 2003-2004
|
Chris@16
|
6 // Copyright Aleksey Gurtovoy 2004
|
Chris@16
|
7 //
|
Chris@16
|
8 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
9 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
10 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
11 //
|
Chris@16
|
12 // See http://www.boost.org/libs/mpl for documentation.
|
Chris@16
|
13
|
Chris@101
|
14 // $Id$
|
Chris@101
|
15 // $Date$
|
Chris@101
|
16 // $Revision$
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/mpl/begin_end.hpp>
|
Chris@16
|
19 #include <boost/mpl/iterator_category.hpp>
|
Chris@16
|
20 #include <boost/mpl/advance.hpp>
|
Chris@16
|
21 #include <boost/mpl/distance.hpp>
|
Chris@16
|
22 #include <boost/mpl/next_prior.hpp>
|
Chris@16
|
23 #include <boost/mpl/deref.hpp>
|
Chris@16
|
24 #include <boost/mpl/min_max.hpp>
|
Chris@16
|
25 #include <boost/mpl/pair.hpp>
|
Chris@16
|
26 #include <boost/mpl/iterator_tags.hpp>
|
Chris@16
|
27 #include <boost/mpl/aux_/config/ctps.hpp>
|
Chris@16
|
28 #include <boost/mpl/aux_/na_spec.hpp>
|
Chris@16
|
29
|
Chris@16
|
30 namespace boost { namespace mpl {
|
Chris@16
|
31
|
Chris@16
|
32 namespace aux {
|
Chris@16
|
33 struct pair_iter_tag;
|
Chris@16
|
34
|
Chris@16
|
35 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
Chris@16
|
36
|
Chris@16
|
37 template< typename Iter1, typename Iter2, typename Category >
|
Chris@16
|
38 struct pair_iter;
|
Chris@16
|
39
|
Chris@16
|
40 template< typename Category > struct prior_pair_iter
|
Chris@16
|
41 {
|
Chris@16
|
42 template< typename Iter1, typename Iter2 > struct apply
|
Chris@16
|
43 {
|
Chris@16
|
44 typedef typename mpl::prior<Iter1>::type i1_;
|
Chris@16
|
45 typedef typename mpl::prior<Iter2>::type i2_;
|
Chris@16
|
46 typedef pair_iter<i1_,i2_,Category> type;
|
Chris@16
|
47 };
|
Chris@16
|
48 };
|
Chris@16
|
49
|
Chris@16
|
50 template<> struct prior_pair_iter<forward_iterator_tag>
|
Chris@16
|
51 {
|
Chris@16
|
52 template< typename Iter1, typename Iter2 > struct apply
|
Chris@16
|
53 {
|
Chris@16
|
54 typedef pair_iter<Iter1,Iter2,forward_iterator_tag> type;
|
Chris@16
|
55 };
|
Chris@16
|
56 };
|
Chris@16
|
57
|
Chris@16
|
58 #endif
|
Chris@16
|
59 }
|
Chris@16
|
60
|
Chris@16
|
61 template<
|
Chris@16
|
62 typename Iter1
|
Chris@16
|
63 , typename Iter2
|
Chris@16
|
64 , typename Category
|
Chris@16
|
65 >
|
Chris@16
|
66 struct pair_iter
|
Chris@16
|
67 {
|
Chris@16
|
68 typedef aux::pair_iter_tag tag;
|
Chris@16
|
69 typedef Category category;
|
Chris@16
|
70 typedef Iter1 first;
|
Chris@16
|
71 typedef Iter2 second;
|
Chris@16
|
72
|
Chris@16
|
73 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
Chris@16
|
74 typedef pair<
|
Chris@16
|
75 typename deref<Iter1>::type
|
Chris@16
|
76 , typename deref<Iter2>::type
|
Chris@16
|
77 > type;
|
Chris@16
|
78
|
Chris@16
|
79 typedef typename mpl::next<Iter1>::type i1_;
|
Chris@16
|
80 typedef typename mpl::next<Iter2>::type i2_;
|
Chris@16
|
81 typedef pair_iter<i1_,i2_,Category> next;
|
Chris@16
|
82
|
Chris@16
|
83 typedef apply_wrap2< aux::prior_pair_iter<Category>,Iter1,Iter2 >::type prior;
|
Chris@16
|
84 #endif
|
Chris@16
|
85 };
|
Chris@16
|
86
|
Chris@16
|
87
|
Chris@16
|
88 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
Chris@16
|
89
|
Chris@16
|
90 template< typename Iter1, typename Iter2, typename C >
|
Chris@16
|
91 struct deref< pair_iter<Iter1,Iter2,C> >
|
Chris@16
|
92 {
|
Chris@16
|
93 typedef pair<
|
Chris@16
|
94 typename deref<Iter1>::type
|
Chris@16
|
95 , typename deref<Iter2>::type
|
Chris@16
|
96 > type;
|
Chris@16
|
97 };
|
Chris@16
|
98
|
Chris@16
|
99 template< typename Iter1, typename Iter2, typename C >
|
Chris@16
|
100 struct next< pair_iter<Iter1,Iter2,C> >
|
Chris@16
|
101 {
|
Chris@16
|
102 typedef typename mpl::next<Iter1>::type i1_;
|
Chris@16
|
103 typedef typename mpl::next<Iter2>::type i2_;
|
Chris@16
|
104 typedef pair_iter<i1_,i2_,C> type;
|
Chris@16
|
105 };
|
Chris@16
|
106
|
Chris@16
|
107 template< typename Iter1, typename Iter2, typename C >
|
Chris@16
|
108 struct prior< pair_iter<Iter1,Iter2,C> >
|
Chris@16
|
109 {
|
Chris@16
|
110 typedef typename mpl::prior<Iter1>::type i1_;
|
Chris@16
|
111 typedef typename mpl::prior<Iter2>::type i2_;
|
Chris@16
|
112 typedef pair_iter<i1_,i2_,C> type;
|
Chris@16
|
113 };
|
Chris@16
|
114
|
Chris@16
|
115 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
Chris@16
|
116
|
Chris@16
|
117
|
Chris@16
|
118 template<> struct advance_impl<aux::pair_iter_tag>
|
Chris@16
|
119 {
|
Chris@16
|
120 template< typename Iter, typename D > struct apply
|
Chris@16
|
121 {
|
Chris@16
|
122 typedef typename mpl::advance< typename Iter::first,D >::type i1_;
|
Chris@16
|
123 typedef typename mpl::advance< typename Iter::second,D >::type i2_;
|
Chris@16
|
124 typedef pair_iter<i1_,i2_,typename Iter::category> type;
|
Chris@16
|
125 };
|
Chris@16
|
126 };
|
Chris@16
|
127
|
Chris@16
|
128 template<> struct distance_impl<aux::pair_iter_tag>
|
Chris@16
|
129 {
|
Chris@16
|
130 template< typename Iter1, typename Iter2 > struct apply
|
Chris@16
|
131 {
|
Chris@16
|
132 // agurt, 10/nov/04: MSVC 6.5 ICE-s on forwarding
|
Chris@16
|
133 typedef typename mpl::distance<
|
Chris@16
|
134 typename first<Iter1>::type
|
Chris@16
|
135 , typename first<Iter2>::type
|
Chris@16
|
136 >::type type;
|
Chris@16
|
137 };
|
Chris@16
|
138 };
|
Chris@16
|
139
|
Chris@16
|
140
|
Chris@16
|
141 template<
|
Chris@16
|
142 typename BOOST_MPL_AUX_NA_PARAM(Sequence1)
|
Chris@16
|
143 , typename BOOST_MPL_AUX_NA_PARAM(Sequence2)
|
Chris@16
|
144 >
|
Chris@16
|
145 struct pair_view
|
Chris@16
|
146 {
|
Chris@16
|
147 typedef nested_begin_end_tag tag;
|
Chris@16
|
148
|
Chris@16
|
149 typedef typename begin<Sequence1>::type iter1_;
|
Chris@16
|
150 typedef typename begin<Sequence2>::type iter2_;
|
Chris@16
|
151 typedef typename min<
|
Chris@16
|
152 typename iterator_category<iter1_>::type
|
Chris@16
|
153 , typename iterator_category<iter2_>::type
|
Chris@16
|
154 >::type category_;
|
Chris@16
|
155
|
Chris@16
|
156 typedef pair_iter<iter1_,iter2_,category_> begin;
|
Chris@16
|
157
|
Chris@16
|
158 typedef pair_iter<
|
Chris@16
|
159 typename end<Sequence1>::type
|
Chris@16
|
160 , typename end<Sequence2>::type
|
Chris@16
|
161 , category_
|
Chris@16
|
162 > end;
|
Chris@16
|
163 };
|
Chris@16
|
164
|
Chris@16
|
165 BOOST_MPL_AUX_NA_SPEC(2, pair_view)
|
Chris@16
|
166
|
Chris@16
|
167 }}
|
Chris@16
|
168
|
Chris@16
|
169 #endif // BOOST_MPL_PAIR_VIEW_HPP_INCLUDED
|