Files
boost_mpl/include/boost/mpl/advance.hpp
T

77 lines
1.9 KiB
C++
Raw Normal View History

2002-09-15 22:13:24 +00:00
#ifndef BOOST_MPL_ADVANCE_HPP_INCLUDED
#define BOOST_MPL_ADVANCE_HPP_INCLUDED
2004-09-02 15:41:37 +00:00
// Copyright Aleksey Gurtovoy 2000-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
// $Source$
// $Date$
// $Revision$
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
#include <boost/mpl/advance_fwd.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/negate.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/tag.hpp>
#include <boost/mpl/apply_wrap.hpp>
#include <boost/mpl/aux_/advance_forward.hpp>
#include <boost/mpl/aux_/advance_backward.hpp>
#include <boost/mpl/aux_/value_wknd.hpp>
#include <boost/mpl/aux_/na_spec.hpp>
#include <boost/mpl/aux_/nttp_decl.hpp>
2004-09-02 15:41:37 +00:00
namespace boost { namespace mpl {
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
// default implementation for forward/bidirectional iterators
template< typename Tag >
2002-09-15 22:13:24 +00:00
struct advance_impl
{
2004-09-02 15:41:37 +00:00
template< typename Iterator, typename N > struct apply
{
typedef typename less< N,long_<0> >::type backward_;
typedef typename if_< backward_, negate<N>, N >::type offset_;
2003-03-10 02:27:06 +00:00
2004-09-02 15:41:37 +00:00
typedef typename if_<
backward_
, aux::advance_backward< BOOST_MPL_AUX_VALUE_WKND(offset_)::value >
, aux::advance_forward< BOOST_MPL_AUX_VALUE_WKND(offset_)::value >
>::type f_;
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
typedef typename apply_wrap1<f_,Iterator>::type type;
};
2002-09-15 22:13:24 +00:00
};
2003-03-11 11:59:49 +00:00
2002-09-15 22:13:24 +00:00
template<
2004-09-02 15:41:37 +00:00
typename BOOST_MPL_AUX_NA_PARAM(Iterator)
, typename BOOST_MPL_AUX_NA_PARAM(N)
2002-09-15 22:13:24 +00:00
>
struct advance
2004-09-02 15:41:37 +00:00
: advance_impl< typename tag<Iterator>::type >
::template apply<Iterator,N>
2002-09-15 22:13:24 +00:00
{
};
template<
typename Iterator
2002-12-09 05:20:25 +00:00
, BOOST_MPL_AUX_NTTP_DECL(long, N)
2002-09-15 22:13:24 +00:00
>
struct advance_c
2004-09-02 15:41:37 +00:00
: advance_impl< typename tag<Iterator>::type >
::template apply<Iterator,long_<N> >
2002-09-15 22:13:24 +00:00
{
};
2004-09-02 15:41:37 +00:00
BOOST_MPL_AUX_NA_SPEC(2, advance)
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
}}
2002-09-15 22:13:24 +00:00
#endif // BOOST_MPL_ADVANCE_HPP_INCLUDED