File indexing completed on 2025-01-18 09:41:56
0001
0002 #ifndef BOOST_MPL_PAIR_VIEW_HPP_INCLUDED
0003 #define BOOST_MPL_PAIR_VIEW_HPP_INCLUDED
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <boost/mpl/begin_end.hpp>
0019 #include <boost/mpl/iterator_category.hpp>
0020 #include <boost/mpl/advance.hpp>
0021 #include <boost/mpl/distance.hpp>
0022 #include <boost/mpl/next_prior.hpp>
0023 #include <boost/mpl/deref.hpp>
0024 #include <boost/mpl/min_max.hpp>
0025 #include <boost/mpl/pair.hpp>
0026 #include <boost/mpl/iterator_tags.hpp>
0027 #include <boost/mpl/aux_/config/ctps.hpp>
0028 #include <boost/mpl/aux_/na_spec.hpp>
0029
0030 namespace boost { namespace mpl {
0031
0032 namespace aux {
0033 struct pair_iter_tag;
0034
0035 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0036
0037 template< typename Iter1, typename Iter2, typename Category >
0038 struct pair_iter;
0039
0040 template< typename Category > struct prior_pair_iter
0041 {
0042 template< typename Iter1, typename Iter2 > struct apply
0043 {
0044 typedef typename mpl::prior<Iter1>::type i1_;
0045 typedef typename mpl::prior<Iter2>::type i2_;
0046 typedef pair_iter<i1_,i2_,Category> type;
0047 };
0048 };
0049
0050 template<> struct prior_pair_iter<forward_iterator_tag>
0051 {
0052 template< typename Iter1, typename Iter2 > struct apply
0053 {
0054 typedef pair_iter<Iter1,Iter2,forward_iterator_tag> type;
0055 };
0056 };
0057
0058 #endif
0059 }
0060
0061 template<
0062 typename Iter1
0063 , typename Iter2
0064 , typename Category
0065 >
0066 struct pair_iter
0067 {
0068 typedef aux::pair_iter_tag tag;
0069 typedef Category category;
0070 typedef Iter1 first;
0071 typedef Iter2 second;
0072
0073 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0074 typedef pair<
0075 typename deref<Iter1>::type
0076 , typename deref<Iter2>::type
0077 > type;
0078
0079 typedef typename mpl::next<Iter1>::type i1_;
0080 typedef typename mpl::next<Iter2>::type i2_;
0081 typedef pair_iter<i1_,i2_,Category> next;
0082
0083 typedef apply_wrap2< aux::prior_pair_iter<Category>,Iter1,Iter2 >::type prior;
0084 #endif
0085 };
0086
0087
0088 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0089
0090 template< typename Iter1, typename Iter2, typename C >
0091 struct deref< pair_iter<Iter1,Iter2,C> >
0092 {
0093 typedef pair<
0094 typename deref<Iter1>::type
0095 , typename deref<Iter2>::type
0096 > type;
0097 };
0098
0099 template< typename Iter1, typename Iter2, typename C >
0100 struct next< pair_iter<Iter1,Iter2,C> >
0101 {
0102 typedef typename mpl::next<Iter1>::type i1_;
0103 typedef typename mpl::next<Iter2>::type i2_;
0104 typedef pair_iter<i1_,i2_,C> type;
0105 };
0106
0107 template< typename Iter1, typename Iter2, typename C >
0108 struct prior< pair_iter<Iter1,Iter2,C> >
0109 {
0110 typedef typename mpl::prior<Iter1>::type i1_;
0111 typedef typename mpl::prior<Iter2>::type i2_;
0112 typedef pair_iter<i1_,i2_,C> type;
0113 };
0114
0115 #endif
0116
0117
0118 template<> struct advance_impl<aux::pair_iter_tag>
0119 {
0120 template< typename Iter, typename D > struct apply
0121 {
0122 typedef typename mpl::advance< typename Iter::first,D >::type i1_;
0123 typedef typename mpl::advance< typename Iter::second,D >::type i2_;
0124 typedef pair_iter<i1_,i2_,typename Iter::category> type;
0125 };
0126 };
0127
0128 template<> struct distance_impl<aux::pair_iter_tag>
0129 {
0130 template< typename Iter1, typename Iter2 > struct apply
0131 {
0132
0133 typedef typename mpl::distance<
0134 typename first<Iter1>::type
0135 , typename first<Iter2>::type
0136 >::type type;
0137 };
0138 };
0139
0140
0141 template<
0142 typename BOOST_MPL_AUX_NA_PARAM(Sequence1)
0143 , typename BOOST_MPL_AUX_NA_PARAM(Sequence2)
0144 >
0145 struct pair_view
0146 {
0147 typedef nested_begin_end_tag tag;
0148
0149 typedef typename begin<Sequence1>::type iter1_;
0150 typedef typename begin<Sequence2>::type iter2_;
0151 typedef typename min<
0152 typename iterator_category<iter1_>::type
0153 , typename iterator_category<iter2_>::type
0154 >::type category_;
0155
0156 typedef pair_iter<iter1_,iter2_,category_> begin;
0157
0158 typedef pair_iter<
0159 typename end<Sequence1>::type
0160 , typename end<Sequence2>::type
0161 , category_
0162 > end;
0163 };
0164
0165 BOOST_MPL_AUX_NA_SPEC(2, pair_view)
0166
0167 }}
0168
0169 #endif