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