os/ossrv/ossrv_pub/boost_apis/boost/mpl/advance.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_ADVANCE_HPP_INCLUDED
sl@0
     3
#define BOOST_MPL_ADVANCE_HPP_INCLUDED
sl@0
     4
sl@0
     5
// Copyright Aleksey Gurtovoy 2000-2004
sl@0
     6
//
sl@0
     7
// Distributed under the Boost Software License, Version 1.0. 
sl@0
     8
// (See accompanying file LICENSE_1_0.txt or copy at 
sl@0
     9
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
    10
//
sl@0
    11
// See http://www.boost.org/libs/mpl for documentation.
sl@0
    12
sl@0
    13
// $Source: /cvsroot/boost/boost/boost/mpl/advance.hpp,v $
sl@0
    14
// $Date: 2004/09/02 15:40:41 $
sl@0
    15
// $Revision: 1.9 $
sl@0
    16
sl@0
    17
#include <boost/mpl/advance_fwd.hpp>
sl@0
    18
#include <boost/mpl/less.hpp>
sl@0
    19
#include <boost/mpl/negate.hpp>
sl@0
    20
#include <boost/mpl/long.hpp>
sl@0
    21
#include <boost/mpl/if.hpp>
sl@0
    22
#include <boost/mpl/tag.hpp>
sl@0
    23
#include <boost/mpl/apply_wrap.hpp>
sl@0
    24
#include <boost/mpl/aux_/advance_forward.hpp>
sl@0
    25
#include <boost/mpl/aux_/advance_backward.hpp>
sl@0
    26
#include <boost/mpl/aux_/value_wknd.hpp>
sl@0
    27
#include <boost/mpl/aux_/na_spec.hpp>
sl@0
    28
#include <boost/mpl/aux_/nttp_decl.hpp>
sl@0
    29
sl@0
    30
namespace boost { namespace mpl {
sl@0
    31
sl@0
    32
// default implementation for forward/bidirectional iterators
sl@0
    33
template< typename Tag >
sl@0
    34
struct advance_impl
sl@0
    35
{
sl@0
    36
    template< typename Iterator, typename N > struct apply
sl@0
    37
    {
sl@0
    38
        typedef typename less< N,long_<0> >::type backward_;
sl@0
    39
        typedef typename if_< backward_, negate<N>, N >::type offset_;
sl@0
    40
sl@0
    41
        typedef typename if_<
sl@0
    42
              backward_
sl@0
    43
            , aux::advance_backward< BOOST_MPL_AUX_VALUE_WKND(offset_)::value >
sl@0
    44
            , aux::advance_forward< BOOST_MPL_AUX_VALUE_WKND(offset_)::value >
sl@0
    45
            >::type f_;
sl@0
    46
sl@0
    47
        typedef typename apply_wrap1<f_,Iterator>::type type;
sl@0
    48
    };
sl@0
    49
};
sl@0
    50
sl@0
    51
sl@0
    52
template<
sl@0
    53
      typename BOOST_MPL_AUX_NA_PARAM(Iterator)
sl@0
    54
    , typename BOOST_MPL_AUX_NA_PARAM(N)
sl@0
    55
    >
sl@0
    56
struct advance
sl@0
    57
    : advance_impl< typename tag<Iterator>::type >
sl@0
    58
        ::template apply<Iterator,N>
sl@0
    59
{
sl@0
    60
};
sl@0
    61
sl@0
    62
template<
sl@0
    63
      typename Iterator
sl@0
    64
    , BOOST_MPL_AUX_NTTP_DECL(long, N)
sl@0
    65
    >
sl@0
    66
struct advance_c
sl@0
    67
    : advance_impl< typename tag<Iterator>::type >
sl@0
    68
        ::template apply<Iterator,long_<N> >
sl@0
    69
{
sl@0
    70
};
sl@0
    71
sl@0
    72
BOOST_MPL_AUX_NA_SPEC(2, advance)
sl@0
    73
sl@0
    74
}}
sl@0
    75
sl@0
    76
#endif // BOOST_MPL_ADVANCE_HPP_INCLUDED